package server

import "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server"

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

Index

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().

Source Files

server.go

Version
v1.18.0 (latest)
Published
Apr 3, 2025
Platform
windows/amd64
Imports
10 packages
Last checked
8 hours ago

Tools for package owners.