Documentation ¶
Overview ¶
Package server provides runtime functionality for fake servers. Application code won't need to import this package.
Index ¶
- func GetError(e fake.ErrorResponder, req *http.Request) error
- func GetResponse[T any](r fake.Responder[T]) T
- func MarshalResponseAsByteArray(content ResponseContent, body []byte, format azexported.Base64Encoding, ...) (*http.Response, error)
- func MarshalResponseAsJSON(content ResponseContent, v any, req *http.Request) (*http.Response, error)
- func MarshalResponseAsText(content ResponseContent, body *string, req *http.Request) (*http.Response, error)
- func MarshalResponseAsXML(content ResponseContent, v any, req *http.Request) (*http.Response, error)
- func NewResponse(content ResponseContent, req *http.Request, opts *ResponseOptions) (*http.Response, error)
- func PagerResponderInjectNextLinks[T any](p *fake.PagerResponder[T], req *http.Request, ...)
- func PagerResponderMore[T any](p *fake.PagerResponder[T]) bool
- func PagerResponderNext[T any](p *fake.PagerResponder[T], req *http.Request) (*http.Response, error)
- func PollerResponderMore[T any](p *fake.PollerResponder[T]) bool
- func PollerResponderNext[T any](p *fake.PollerResponder[T], req *http.Request) (*http.Response, error)
- func SanitizePagerPollerPath(path string) string
- func UnmarshalRequestAsByteArray(req *http.Request, format azexported.Base64Encoding) ([]byte, error)
- func UnmarshalRequestAsJSON[T any](req *http.Request) (T, error)
- func UnmarshalRequestAsText(req *http.Request) (string, error)
- func UnmarshalRequestAsXML[T any](req *http.Request) (T, error)
- type ResponseContent
- type ResponseOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetError ¶
func GetError(e fake.ErrorResponder, req *http.Request) error
GetError returns the error for this responder. This function is called by the fake server internals.
func GetResponse ¶
GetResponse returns the response associated with the Responder. This function is called by the fake server internals.
func MarshalResponseAsByteArray ¶
func MarshalResponseAsByteArray(content ResponseContent, body []byte, format azexported.Base64Encoding, req *http.Request) (*http.Response, error)
MarshalResponseAsByteArray base-64 encodes the body with the specified format and returns it in a *http.Response. This function is called by the fake server internals.
func MarshalResponseAsJSON ¶
func MarshalResponseAsJSON(content ResponseContent, v any, req *http.Request) (*http.Response, error)
MarshalResponseAsJSON converts the body into JSON and returns it in a *http.Response. This function is called by the fake server internals.
func MarshalResponseAsText ¶
func MarshalResponseAsText(content ResponseContent, body *string, req *http.Request) (*http.Response, error)
MarshalResponseAsText converts the body into text and returns it in a *http.Response. This function is called by the fake server internals.
func MarshalResponseAsXML ¶
func MarshalResponseAsXML(content ResponseContent, v any, req *http.Request) (*http.Response, error)
MarshalResponseAsXML converts the body into XML and returns it in a *http.Response. This function is called by the fake server internals.
func NewResponse ¶
func NewResponse(content ResponseContent, req *http.Request, opts *ResponseOptions) (*http.Response, error)
NewResponse returns a *http.Response. This function is called by the fake server internals.
func PagerResponderInjectNextLinks ¶
func PagerResponderInjectNextLinks[T any](p *fake.PagerResponder[T], req *http.Request, inject func(page *T, createLink func() string))
PagerResponderInjectNextLinks is used to populate the nextLink field. The inject callback is executed for every T in the sequence except for the last one. This function is called by the fake server internals.
func PagerResponderMore ¶
func PagerResponderMore[T any](p *fake.PagerResponder[T]) bool
PagerResponderMore returns true if there are more responses for consumption. This function is called by the fake server internals.
func PagerResponderNext ¶
func PagerResponderNext[T any](p *fake.PagerResponder[T], req *http.Request) (*http.Response, error)
PagerResponderNext returns the next response in the sequence (a T or an error). This function is called by the fake server internals.
func PollerResponderMore ¶
func PollerResponderMore[T any](p *fake.PollerResponder[T]) bool
PollerResponderMore returns true if there are more responses for consumption. This function is called by the fake server internals.
func PollerResponderNext ¶
func PollerResponderNext[T any](p *fake.PollerResponder[T], req *http.Request) (*http.Response, error)
PollerResponderNext returns the next response in the sequence (a *http.Response or an error). This function is called by the fake server internals.
func SanitizePagerPollerPath ¶
SanitizePagerPollerPath removes any fake-appended suffix from a URL's path. This function is called by the fake server internals.
func UnmarshalRequestAsByteArray ¶
func UnmarshalRequestAsByteArray(req *http.Request, format azexported.Base64Encoding) ([]byte, error)
UnmarshalRequestAsByteArray base-64 decodes the body in the specified format. This function is called by the fake server internals.
func UnmarshalRequestAsJSON ¶
UnmarshalRequestAsJSON unmarshalls the request body into an instance of T. This function is called by the fake server internals.
func UnmarshalRequestAsText ¶
UnmarshalRequestAsText unmarshalls the request body into a string. This function is called by the fake server internals.
Types ¶
type ResponseContent ¶
type ResponseContent = exported.ResponseContent
ResponseContent is used when building the *http.Response. This type is used by the fake server internals.
func GetResponseContent ¶
func GetResponseContent[T any](r fake.Responder[T]) ResponseContent
GetResponseContent returns the ResponseContent associated with the Responder. This function is called by the fake server internals.
type ResponseOptions ¶
type ResponseOptions = exported.ResponseOptions
ResponseOptions contains the optional values for NewResponse().