Documentation
¶
Index ¶
- Constants
- func FilteredOperationRequestMap(op *BaseOperationRequest, opFields []string) map[string]interface{}
- func FlattenOperationRequest(op *BaseOperationRequest) map[string]interface{}
- func NewOperationRequest(region string, opts OperationRequestOptions) mux.MiddlewareFunc
- func OperationRequestWithContext(ctx context.Context, op *BaseOperationRequest) context.Context
- type BaseOperationRequest
- type OperationRequestCustomizerFunc
- type OperationRequestOptions
Constants ¶
View Source
const ARMTimeout = 60 * time.Second
Variables ¶
This section is empty.
Functions ¶
func FilteredOperationRequestMap ¶ added in v0.0.33
func FilteredOperationRequestMap(op *BaseOperationRequest, opFields []string) map[string]interface{}
Add a new method to encapsulate the filtered operation request logic.
func FlattenOperationRequest ¶ added in v0.0.33
func FlattenOperationRequest(op *BaseOperationRequest) map[string]interface{}
func NewOperationRequest ¶
func NewOperationRequest(region string, opts OperationRequestOptions) mux.MiddlewareFunc
NewOperationRequest creates an operationRequestMiddleware using the provided options. The options contains the customizer.
func OperationRequestWithContext ¶
func OperationRequestWithContext(ctx context.Context, op *BaseOperationRequest) context.Context
Types ¶
type BaseOperationRequest ¶
type BaseOperationRequest struct {
APIVersion string
SubscriptionID string
ResourceGroup string
CorrelationID string
OperationID string
AcceptedLanguage string
TargetURI string
HttpMethod string
Body []byte
RouteName string
Request *http.Request `json:"-"`
Region string
ResourceType string
ResourceName string
// extra fields can be stored in Extras if needed
// keep this as concrete type instead of generic to grab struct from context in context logger
// can't grab the struct if user defines their own type for extras
Extras map[string]interface{} `json:"extras"`
}
BaseOperationRequest contains the common fields
func NewBaseOperationRequest ¶
func NewBaseOperationRequest(req *http.Request, region string, opts OperationRequestOptions) (*BaseOperationRequest, error)
NewBaseOperationRequest constructs the BaseOperationRequest. It extracts data from the HTTP request in the following order:
- URL and Query: Extract api-version and target URI.
- Headers: Extract correlation ID, accepted language, and operation ID.
- Route Variables: Extract subscription ID, resource group, resource provider/type, and resource name.
- Method & Body: Capture the HTTP method and read the request body.
- Route Name: Optionally capture the route name from mux.CurrentRoute.
- Customization: Allow further customization of extras.
func OperationRequestFromContext ¶
func OperationRequestFromContext(ctx context.Context) *BaseOperationRequest
type OperationRequestCustomizerFunc ¶
type OperationRequestCustomizerFunc func(extras map[string]interface{}, headers http.Header, vars map[string]string) error
OperationRequestCustomizerFunc is a function to customize the extras.
type OperationRequestOptions ¶
type OperationRequestOptions struct {
Customizer OperationRequestCustomizerFunc
}
Click to show internal directories.
Click to hide internal directories.