operationrequest

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ARMTimeout = 60 * time.Second

Variables

This section is empty.

Functions

func NewOperationRequest

func NewOperationRequest[T any](region string, opts OperationRequestOptions[T]) mux.MiddlewareFunc

NewOperationRequest creates an operationRequestMiddleware using the provided options. The options contains both the Extras value and its customizer.

func OperationRequestWithContext

func OperationRequestWithContext[T any](ctx context.Context, op *BaseOperationRequest[T]) context.Context

Types

type BaseOperationRequest

type BaseOperationRequest[T any] 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
	Extras T
}

BaseOperationRequest contains the common fields.

func NewBaseOperationRequest

func NewBaseOperationRequest[T any](req *http.Request, region string, opts OperationRequestOptions[T]) (*BaseOperationRequest[T], 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[T any](ctx context.Context) *BaseOperationRequest[T]

type OperationRequestCustomizerFunc

type OperationRequestCustomizerFunc[T any] func(extras *T, headers http.Header, vars map[string]string) error

OperationRequestCustomizerFunc is a function to customize the extras.

type OperationRequestOptions

type OperationRequestOptions[T any] struct {
	Extras     T
	Customizer OperationRequestCustomizerFunc[T]
}

Jump to

Keyboard shortcuts

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