operationrequest

package
v0.0.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

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 both the Extras value and its 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:

  1. URL and Query: Extract api-version and target URI.
  2. Headers: Extract correlation ID, accepted language, and operation ID.
  3. Route Variables: Extract subscription ID, resource group, resource provider/type, and resource name.
  4. Method & Body: Capture the HTTP method and read the request body.
  5. Route Name: Optionally capture the route name from mux.CurrentRoute.
  6. 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 {
	Extras     map[string]interface{}
	Customizer OperationRequestCustomizerFunc
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL