server

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 10 Imported by: 265

Documentation

Overview

Package server provides runtime functionality for fake servers. Application code won't need to import this package.

Index

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

func GetResponse[T any](r fake.Responder[T]) T

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[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

func SanitizePagerPollerPath(path string) string

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

func UnmarshalRequestAsJSON[T any](req *http.Request) (T, error)

UnmarshalRequestAsJSON unmarshalls the request body into an instance of T. This function is called by the fake server internals.

func UnmarshalRequestAsText

func UnmarshalRequestAsText(req *http.Request) (string, error)

UnmarshalRequestAsText unmarshalls the request body into a string. This function is called by the fake server internals.

func UnmarshalRequestAsXML

func UnmarshalRequestAsXML[T any](req *http.Request) (T, error)

UnmarshalRequestAsXML unmarshalls the request body into an instance of T. 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().

Jump to

Keyboard shortcuts

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