Documentation ¶
Index ¶
- Variables
- func FromJSON[T any](response *http.Response, v *T) error
- func IsNil(a interface{}) bool
- func ParseResponse[T Response](response *http.Response, value *T) error
- func ResetCalls(calls ...*mock.Call)
- func ToQueryMap(source interface{}) (map[string]string, error)
- func WithMethod(method HttpMethod) requestInformationOption
- func WithPathParams(pathParameters map[string]string) requestInformationOption
- func WithURITemplate(template string) requestInformationOption
- type Client2
- type ErrorMapping
- type HttpMethod
- type RequestBuilder
- type RequestBuilder2
- type RequestConfiguration
- type RequestConfigurationOption
- func WithData(data interface{}) RequestConfigurationOption
- func WithErrorMapping(errorMapping ErrorMapping) RequestConfigurationOption
- func WithHeader[T any](header T) RequestConfigurationOption
- func WithQueryParameters[T any](queryParams T) RequestConfigurationOption
- func WithResponse(response Response) RequestConfigurationOption
- type RequestHeader
- type RequestInformation
- type RequestOption
- type RequestOptionKey
- type Response
- type Test
- type UrlInformation
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyURI = errors.New("uri cannot be empty") ErrNilPathParameters = errors.New("uri template parameters cannot be nil") ErrNilQueryParamters = errors.New("uri query parameters cannot be nil") ErrMissingBasePathParam = errors.New("pathParameters must contain a value for \"baseurl\" for the URL to be built") ErrMissingBasePathTemplate = errors.New("template must contain a placeholder for \"{+baseurl}\" for the URL to be built") ErrInvalidHeaderType = errors.New("headers must be a pointer or an http.Header") ErrEmptyRawURL = errors.New("empty raw URL") ErrMissingSchema = errors.New("URL is missing schema") ErrNilResponse = errors.New("Response is nil") ErrNilResponseBody = errors.New("response body is nil") ErrNilSource = errors.New("source is nil") ErrNilCredential = errors.New("credential is nil") //Page Iterator ErrNilClient = errors.New("client can't be nil") ErrNilResult = errors.New("result property missing in response object") ErrWrongResponseType = errors.New("incorrect Response Type") ErrParsing = errors.New("parsing nextLink url failed") ErrNilCallback = errors.New("callback can't be nil") //Authorization Provider ErrNilRequest = errors.New("request can't be nil") )
Functions ¶
func ParseResponse ¶
ParseResponse[T] parses the HTTP Response to the provided type
func ResetCalls ¶
func ToQueryMap ¶
ToQueryMap converts a struct to query parameter map
func WithMethod ¶
func WithMethod(method HttpMethod) requestInformationOption
func WithPathParams ¶
func WithURITemplate ¶
func WithURITemplate(template string) requestInformationOption
Types ¶
type Client2 ¶
type Client2 interface { Send(RequestInformation, ErrorMapping) (*http.Response, error) SendWithContext(context.Context, RequestInformation, ErrorMapping) (*http.Response, error) GetBaseURL() string }
type ErrorMapping ¶
type HttpMethod ¶
type HttpMethod int //nolint:stylecheck
Represents the HTTP method used by a request.
const ( // The HTTP GET method. GET HttpMethod = iota // The HTTP POST method. POST // The HTTP PATCH method. PATCH // The HTTP DELETE method. DELETE // The HTTP OPTIONS method. OPTIONS // The HTTP CONNECT method. CONNECT // The HTTP PUT method. PUT // The HTTP TRACE method. TRACE // The HTTP HEAD method. HEAD )
func (HttpMethod) String ¶
func (m HttpMethod) String() string
String returns the string representation of the HTTP method.
type RequestBuilder ¶
type RequestBuilder interface { SendDelete2(config *RequestConfiguration) error SendGet2(config *RequestConfiguration) error SendPost3(config *RequestConfiguration) error SendPut2(config *RequestConfiguration) error ToDeleteRequestInformation(params interface{}) (*RequestInformation, error) ToDeleteRequestInformation2(config *RequestConfiguration) (*RequestInformation, error) ToGetRequestInformation(params interface{}) (*RequestInformation, error) ToGetRequestInformation2(config *RequestConfiguration) (*RequestInformation, error) ToHeadRequestInformation() (*RequestInformation, error) ToPostRequestInformation(data map[string]string, params interface{}) (*RequestInformation, error) ToPostRequestInformation2(data interface{}, params interface{}) (*RequestInformation, error) ToPostRequestInformation3(config interface{}) (*RequestInformation, error) ToPutRequestInformation(data map[string]string, params interface{}) (*RequestInformation, error) ToPutRequestInformation2(config interface{}) (*RequestInformation, error) ToRequestInformation(method HttpMethod, data map[string]string, params interface{}) (*RequestInformation, error) ToRequestInformation2(method HttpMethod, rawData interface{}, params interface{}) (*RequestInformation, error) ToRequestInformation3(method HttpMethod, config *interface{}) (*RequestInformation, error) }
type RequestBuilder2 ¶
type RequestBuilder2 interface { ToRequestInformation(method HttpMethod, config *RequestConfiguration) (RequestInformation, error) GetPathParameters() map[string]string GetClient() Client2 GetURLTemplate() string Send(ctx context.Context, method HttpMethod, opts ...RequestConfigurationOption) (interface{}, error) }
func NewRequestBuilder2 ¶
func NewRequestBuilder2(client Client2, urlTemplate string, pathParameters map[string]string) RequestBuilder2
type RequestConfiguration ¶
type RequestConfiguration struct { Header interface{} QueryParameters interface{} Data interface{} ErrorMapping ErrorMapping Response Response }
func ApplyOptions ¶
func ApplyOptions(opts ...RequestConfigurationOption) *RequestConfiguration
ApplyOptions applies the given options to a RequestConfiguration.
type RequestConfigurationOption ¶
type RequestConfigurationOption func(*RequestConfiguration)
RequestConfigurationOption the functional option type for configuring requests.
func WithData ¶
func WithData(data interface{}) RequestConfigurationOption
WithData sets the data for the request.
func WithErrorMapping ¶
func WithErrorMapping(errorMapping ErrorMapping) RequestConfigurationOption
WithErrorMapping sets the error mapping for the request.
func WithHeader ¶
func WithHeader[T any](header T) RequestConfigurationOption
WithHeader sets the header for the request.
func WithQueryParameters ¶
func WithQueryParameters[T any](queryParams T) RequestConfigurationOption
WithQueryParameters sets the query parameters for the request.
func WithResponse ¶
func WithResponse(response Response) RequestConfigurationOption
WithResponse sets the response handler for the request.
type RequestHeader ¶
type RequestHeader interface { Set(key, value string) Get(key string) string SetAll(headers http.Header) Iterate(callback func(string, []string) bool) }
func NewRequestHeader ¶
func NewRequestHeader() RequestHeader
type RequestInformation ¶
type RequestInformation interface { SetStreamContent(content []byte) GetContent() []byte GetMethod() string GetHeaders() RequestHeader AddQueryParameters(source interface{}) error SetUri(url *url.URL) Url() (string, error) SetContent(content []byte, contentType string) ToRequest() (*http.Request, error) ToRequestWithContext(ctx context.Context) (*http.Request, error) AddHeaders(rawHeaders interface{}) error }
func NewRequestInformation ¶
func NewRequestInformation(opts ...requestInformationOption) RequestInformation
NewRequestInformation creates a new RequestInformation object with default values.
func NewRequestInformationWithMethod ¶
func NewRequestInformationWithMethod(method HttpMethod) RequestInformation
type RequestOption ¶
type RequestOption interface { // GetKey returns the key to store the current option under. GetKey() RequestOptionKey }
Represents a request option.
type RequestOptionKey ¶
type RequestOptionKey struct { // The unique key for the option. Key string }
RequestOptionKey represents a key to store a request option under.
type UrlInformation ¶
type UrlInformation struct { // The Query Parameters of the request. QueryParameters map[string]string // The path parameters to use for the URL template when generating the URI. PathParameters map[string]string // The Url template for the current request. UrlTemplate string //nolint:stylecheck }
UrlInformation represents an abstract Url.
func NewURLInformation ¶
func NewURLInformation() *UrlInformation
NewURLInformation creates a new RequestUri object.
func NewUrlInformation
deprecated
func NewUrlInformation() *UrlInformation
Deprecated: deprecated as of v1.4.0, use `NewURLInformation` instead.
NewUrlInformation creates a new RequestUri object.
func (*UrlInformation) AddQueryParameters ¶
func (uI *UrlInformation) AddQueryParameters(source interface{}) error
AddQueryParameters adds the query parameters to the request by reading the properties from the provided object.
Source Files ¶
- client2.go
- constants.go
- error_mapping.go
- errors.go
- helper.go
- http_method.go
- request_builder.go
- request_builder2.go
- request_configuration.go
- request_configuration_option.go
- request_header.go
- request_information.go
- request_information_option.go
- request_option.go
- request_option_key.go
- response.go
- test.go
- url_information.go