restli

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: BSD-2-Clause Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ProtocolVersion = "2.0.0"

	IDHeader              = "X-RestLi-Id"
	MethodHeader          = "X-RestLi-Method"
	ProtocolVersionHeader = "X-RestLi-Protocol-Version"
	ErrorResponseHeader   = "X-RestLi-Error-Response"
	MethodOverrideHeader  = "X-HTTP-Method-Override"

	ContentTypeHeader          = "Content-Type"
	MultipartMixedContentType  = "multipart/mixed"
	MultipartBoundary          = "boundary"
	ApplicationJsonContentType = "application/json"
	FormUrlEncodedContentType  = "application/x-www-form-urlencoded"
)
View Source
const (
	Method_Unknown = Method(iota)

	Method_get
	Method_create
	Method_delete
	Method_update
	Method_partial_update

	Method_batch_get
	Method_batch_create
	Method_batch_delete
	Method_batch_update
	Method_batch_partial_update

	Method_get_all

	Method_action
	Method_finder
)

Disabled until https://github.com/golang/go/issues/45218 is resolved: go:generate stringer -type=Method -trimprefix Method_

View Source
const (
	PatchField = "patch"
)

Variables

View Source
var MethodNameMapping = func() map[string]Method {
	mapping := make(map[string]Method)
	for m := Method_get; m <= Method_finder; m++ {
		mapping[m.String()] = m
	}
	return mapping
}()
View Source
var NilQueryParams = fmt.Errorf("go-restli: Query params cannot be nil")
View Source
var RequiredPatchRecordFields = restlicodec.RequiredFields{PatchField}
View Source
var StandardLogger stdLogger

StandardLogger represents the standard Logger from the log package (log.std for those inclined to read the source code)

Functions

func AddResponseHeadersCaptor

func AddResponseHeadersCaptor(ctx context.Context) (context.Context, http.Header)

AddResponseHeadersCaptor returns a new context and a http.Header. If the returned context is passed into any Client request, the returned http.Header will be populated with all the headers returned by the server.

func BatchCreate

func BatchCreate[K comparable, V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	entities []V,
	query QueryParamsEncoder,
	readOnlyFields restlicodec.PathSpec,
) (createdEntities []*restlidata.CreatedEntity[K], err error)

BatchCreate executes a batch_create with the given slice of entities

func BatchCreateWithReturnEntity

func BatchCreateWithReturnEntity[K comparable, V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	entities []V,
	query QueryParamsEncoder,
	readOnlyFields restlicodec.PathSpec,
) (createdEntities []*restlidata.CreatedAndReturnedEntity[K, V], err error)

func BatchDelete

func BatchDelete[K comparable](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	keys []K,
	query batchQueryParamsEncoder[K],
) (*restlidata.BatchResponse[K, *restlidata.BatchEntityUpdateResponse], error)

func BatchGet

func BatchGet[K comparable, V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	keys []K,
	query batchQueryParamsEncoder[K],
) (*restlidata.BatchResponse[K, V], error)

func BatchPartialUpdate

func BatchPartialUpdate[K comparable, PV restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	entities map[K]PV,
	query batchQueryParamsEncoder[K],
	createAndReadOnlyFields restlicodec.PathSpec,
) (*restlidata.BatchResponse[K, *restlidata.BatchEntityUpdateResponse], error)

func BatchUpdate

func BatchUpdate[K comparable, V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	entities map[K]V,
	query batchQueryParamsEncoder[K],
	createAndReadOnlyFields restlicodec.PathSpec,
) (*restlidata.BatchResponse[K, *restlidata.BatchEntityUpdateResponse], error)

func BoolPointer

func BoolPointer(v bool) *bool

BoolPointer returns a pointer to the given parameter, useful for inlining setting optional fields

func BytesPointer

func BytesPointer(v []byte) *[]byte

BytesPointer returns a pointer to the given parameter, useful for inlining setting optional fields

func Create

func Create[K any, V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	create V,
	query QueryParamsEncoder,
	readOnlyFields restlicodec.PathSpec,
) (*restlidata.CreatedEntity[K], error)

Create executes a rest.li create request with the given object. The X-RestLi-Id header field will be parsed into id (though a CreateResponseHasNoEntityHeaderError will be returned if the header is not set). The response body will always be ignored.

func CreateWithReturnEntity

func CreateWithReturnEntity[K any, V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	create V,
	query QueryParamsEncoder,
	readOnlyFields restlicodec.PathSpec,
) (*restlidata.CreatedAndReturnedEntity[K, V], error)

CreateWithReturnEntity is like CollectionClient.Create, except it parses the returned entity from the response.

func DecodeTunnelledQuery added in v1.1.0

func DecodeTunnelledQuery(req *http.Request) (err error)

func Delete

func Delete(
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
) error

Delete executes a rest.li delete request

func DoActionRequest

func DoActionRequest(
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
	params restlicodec.Marshaler,
) (err error)

DoActionRequest executes a rest.li Action request and places the given restlicodec.Marshaler in the request's body and discards the response body. Actions with no params are expected to use the EmptyRecord.

func DoActionRequestWithResults

func DoActionRequestWithResults[T any](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
	params restlicodec.Marshaler,
	unmarshaler restlicodec.GenericUnmarshaler[T],
) (t T, err error)

DoActionRequestWithResults executes a rest.li Action request and places the given restlicodec.Marshaler in the request's body, and returns the results after deserialization. Actions with no params are expected to use the EmptyRecord.

func DoAndIgnore

func DoAndIgnore(c *Client, req *http.Request) (*http.Response, error)

DoAndIgnore calls Do and drops the response's body. The response body will always be read to EOF and closed, to ensure the connection can be reused.

func DoAndUnmarshal

func DoAndUnmarshal[V any](
	c *Client,
	req *http.Request,
	unmarshaler restlicodec.GenericUnmarshaler[V],
) (v V, res *http.Response, err error)

DoAndUnmarshal calls Do and attempts to unmarshal the response into the given value. The response body will always be read to EOF and closed, to ensure the connection can be reused.

func EncodeTunnelledQuery added in v1.1.0

func EncodeTunnelledQuery(httpMethod, query string, body []byte) (newBody []byte, headers http.Header)

func ExtraRequestHeaders

func ExtraRequestHeaders(ctx context.Context, f func() (http.Header, error)) context.Context

ExtraRequestHeaders returns a context.Context to be passed into any generated client methods. Upon request creation, the given function will be executed, and the headers will be added to the request before being sent. Note that these headers will not override any existing headers such as Content-Type. Only new headers will be added to the request.

func Find

func Find[V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
) (results *restlidata.Elements[V], err error)

Find executes a rest.li find request

func FindWithMetadata

func FindWithMetadata[V, M restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
) (results *restlidata.ElementsWithMetadata[V, M], err error)

FindWithMetadata executes a rest.li find request for finders that declare metadata

func Float32Pointer

func Float32Pointer(v float32) *float32

Float32Pointer returns a pointer to the given parameter, useful for inlining setting optional fields

func Float64Pointer

func Float64Pointer(v float64) *float64

Float64Pointer returns a pointer to the given parameter, useful for inlining setting optional fields

func Get

func Get[V any](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
) (v V, err error)

func GetActionNameFromContext

func GetActionNameFromContext(ctx context.Context) string

func GetAll

func GetAll[V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
) (results *restlidata.Elements[V], err error)

func GetEntitySegmentsFromContext

func GetEntitySegmentsFromContext(ctx context.Context) []restlicodec.Reader

func GetFinderNameFromContext

func GetFinderNameFromContext(ctx context.Context) string

func Int32Pointer

func Int32Pointer(v int32) *int32

Int32Pointer returns a pointer to the given parameter, useful for inlining setting optional fields

func Int64Pointer

func Int64Pointer(v int64) *int64

Int64Pointer returns a pointer to the given parameter, useful for inlining setting optional fields

func IsErrorResponse

func IsErrorResponse(res *http.Response) error

IsErrorResponse checks the contents of the given http.Response and if the X-RestLi-Error-Response is set to `true`, parses the body of the response into a Error. If the header is not set, but the status code isn't a 2xx code, an UnexpectedStatusCodeError will be returned instead. Note that an UnexpectedStatusCodeError contains the http.Request and http.Response that resulted in this error, therefore an expected non-2xx can always be manually handled/recovered (e.g. a 3xx code redirecting to the HTTPS endpoint).

func NewCreateRequest

func NewCreateRequest(
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
	method Method,
	create restlicodec.Marshaler,
	readOnlyFields restlicodec.PathSpec,
) (*http.Request, error)

func NewDeleteRequest

func NewDeleteRequest(
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
	method Method,
) (*http.Request, error)

NewDeleteRequest creates a DELETE http.Request and sets the expected rest.li headers

func NewGetRequest

func NewGetRequest(
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
	method Method,
) (*http.Request, error)

NewGetRequest creates a GET http.Request and sets the expected rest.li headers

func NewJsonRequest

func NewJsonRequest(
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	query QueryParamsEncoder,
	httpMethod string,
	restLiMethod Method,
	contents restlicodec.Marshaler,
	excludedFields restlicodec.PathSpec,
) (*http.Request, error)

NewJsonRequest creates an http.Request with the given HTTP method and rest.li method, and populates the body of the request with the given restlicodec.Marshaler contents (see RawJsonRequest)

func PartialUpdate

func PartialUpdate[PV restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	patch PV,
	query QueryParamsEncoder,
	createAndReadOnlyFields restlicodec.PathSpec,
) error

PartialUpdate executes a rest.li partial update request with the given patch object

func RegisterAction

func RegisterAction[RP ResourcePathUnmarshaler[RP], P any](
	s Server,
	segments []ResourcePathSegment,
	name string,
	action func(*RequestContext, RP, P) error,
)

func RegisterActionWithResults

func RegisterActionWithResults[RP ResourcePathUnmarshaler[RP], P, R any](
	s Server,
	segments []ResourcePathSegment,
	name string,
	resultsMarshaler restlicodec.GenericMarshaler[R],
	action func(*RequestContext, RP, P) (R, error),
)

func RegisterBatchCreate

func RegisterBatchCreate[K any, RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	readOnlyFields restlicodec.PathSpec,
	batchCreate func(*RequestContext, RP, []V, QP) ([]*restlidata.CreatedEntity[K], error),
)

func RegisterBatchCreateWithReturnEntity

func RegisterBatchCreateWithReturnEntity[K any, RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	readOnlyFields restlicodec.PathSpec,
	batchCreate func(*RequestContext, RP, []V, QP) ([]*restlidata.CreatedAndReturnedEntity[K, V], error),
)

func RegisterBatchDelete

func RegisterBatchDelete[K comparable, RP ResourcePathUnmarshaler[RP], QP batchQueryParamsDecoder[K, QP]](
	s Server,
	segments []ResourcePathSegment,
	batchDelete func(*RequestContext, RP, []K, QP) (*restlidata.BatchResponse[K, *restlidata.BatchEntityUpdateResponse], error),
)

func RegisterBatchGet

func RegisterBatchGet[K comparable, RP ResourcePathUnmarshaler[RP], QP batchQueryParamsDecoder[K, QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	batchGet func(*RequestContext, RP, []K, QP) (*restlidata.BatchResponse[K, V], error),
)

func RegisterBatchPartialUpdate

func RegisterBatchPartialUpdate[K comparable, RP ResourcePathUnmarshaler[RP], QP batchQueryParamsDecoder[K, QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	readAndCreateOnlyFields restlicodec.PathSpec,
	batchPartialUpdate func(*RequestContext, RP, map[K]V, QP) (*restlidata.BatchResponse[K, *restlidata.BatchEntityUpdateResponse], error),
)

func RegisterBatchUpdate

func RegisterBatchUpdate[K comparable, RP ResourcePathUnmarshaler[RP], QP batchQueryParamsDecoder[K, QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	readAndCreateOnlyFields restlicodec.PathSpec,
	batchUpdate func(*RequestContext, RP, map[K]V, QP) (*restlidata.BatchResponse[K, *restlidata.BatchEntityUpdateResponse], error),
)

func RegisterCreate

func RegisterCreate[K any, RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	readOnlyFields restlicodec.PathSpec,
	create func(*RequestContext, RP, V, QP) (*restlidata.CreatedEntity[K], error),
)

func RegisterCreateWithReturnEntity

func RegisterCreateWithReturnEntity[K any, RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	readOnlyFields restlicodec.PathSpec,
	create func(*RequestContext, RP, V, QP) (*restlidata.CreatedAndReturnedEntity[K, V], error),
)

func RegisterDelete

func RegisterDelete[RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP]](
	s Server,
	segments []ResourcePathSegment,
	deleteF func(*RequestContext, RP, QP) error,
)

func RegisterFinder

func RegisterFinder[RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	name string,
	find func(*RequestContext, RP, QP) (*restlidata.Elements[V], error),
)

func RegisterFinderWithMetadata

func RegisterFinderWithMetadata[RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V, M restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	name string,
	find func(*RequestContext, RP, QP) (*restlidata.ElementsWithMetadata[V, M], error),
)

func RegisterGet

func RegisterGet[RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	get func(*RequestContext, RP, QP) (V, error),
)

func RegisterGetAll

func RegisterGetAll[RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	getAll func(*RequestContext, RP, QP) (*restlidata.Elements[V], error),
)

func RegisterPartialUpdate

func RegisterPartialUpdate[RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	excludedFields restlicodec.PathSpec,
	partialUpdate func(*RequestContext, RP, V, QP) error,
)

func RegisterUpdate

func RegisterUpdate[RP ResourcePathUnmarshaler[RP], QP restlicodec.QueryParamsDecoder[QP], V restlicodec.Marshaler](
	s Server,
	segments []ResourcePathSegment,
	readAndCreateOnlyFields restlicodec.PathSpec,
	update func(*RequestContext, RP, V, QP) error,
)

func SetLocation

func SetLocation[K any](ctx *RequestContext, c *restlidata.CreatedEntity[K]) error

func StringPointer

func StringPointer(v string) *string

StringPointer returns a pointer to the given parameter, useful for inlining setting optional fields

func StringPointerf

func StringPointerf(format string, args ...any) *string

StringPointerf formats the given string then returns a pointer to it, useful for inlining setting optional fields

func UnmarshalResourcePath

func UnmarshalResourcePath[T ResourcePathUnmarshaler[T]](segments []restlicodec.Reader) (t T, err error)

func Update

func Update[V restlicodec.Marshaler](
	c *Client,
	ctx context.Context,
	rp ResourcePath,
	update V,
	query QueryParamsEncoder,
	createAndReadOnlyFields restlicodec.PathSpec,
) error

Update executes a rest.li update request with the given update object

Types

type Client

type Client struct {
	*http.Client
	HostnameResolver HostnameResolver
	// Whether missing fields in a restli response should cause a MissingRequiredFields error to be returned. Note that
	// even if the error is returned, the response will still be fully deserialized.
	StrictResponseDeserialization bool
	// When greater than 0, this enables request tunnelling. When a request's query is longer than this value, the
	// request will instead be sent via POST, with the query encoded as a form query and the MethodOverrideHeader set to
	// the original HTTP method.
	QueryTunnellingThreshold int
}

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do is a very thin shim between the standard http.Client.Do. All it does it parse the response into a Error if the RestLi error header is set. A non-nil Response with a non-nil error will only occur if http.Client.Do returns such values (see the corresponding documentation). Otherwise, the response will only be non-nil if the error is nil. All (and only) network-related errors will be of type *url.Error. Other types of errors such as parse errors will use different error types.

type CreateResponseHasNoEntityHeaderError

type CreateResponseHasNoEntityHeaderError struct {
	Response *http.Response
}

CreateResponseHasNoEntityHeaderError is used specifically when a Create request succeeds but the resource implementation does not set the X-RestLi-Id header. This error is recoverable and can be ignored if the response id is not required

func (CreateResponseHasNoEntityHeaderError) Error

type Error

type Error struct {
	restlidata.ErrorResponse
	// Will be non-nil if an error occurred when attempting to deserialize the actual JSON response fields (i.e. Status,
	// Message, ExceptionClass and StackTrace)
	DeserializationError error `json:"-"`
	// The raw response that this error was parsed from. Note that to ensure that the connection can be reused, the Body
	// of the response is fully read into ResponseBody then closed
	Response     *http.Response `json:"-"`
	ResponseBody []byte         `json:"-"`
}

Error is returned by the Do* methods when the X-RestLi-Error-Response header is set to true.

type Filter

type Filter interface {
	// PreRequest is called after the request is parsed and the corresponding method is found. It is not called on any
	// invalid requests. The request's context will have corresponding values for the method, resource segments, entity
	// segments, finder name (only set if the method is Method_finder) and action name (only set if the method is
	// Method_action). Use the corresponding FromContext methods to get the values. If the returned context is non-nil,
	// it will replace the context passed to the actual resource implementation.
	PreRequest(req *http.Request) (context.Context, error)
	// PostRequest is called with the original request context and the response header map right before the response
	// header is written.
	PostRequest(ctx context.Context, responseHeaders http.Header) error
}

Filter implementations can enrich the request as it comes in by adding values to the context. They also receive a callback to add any response headers, if necessary. Filters' PreRequest methods will ve called in the order in which they were passed to NewServer, and PostRequest methods in the inverse order.

type HostnameResolver

type HostnameResolver interface {
	// ResolveHostnameAndContextForQuery takes in the name of the resource for which to resolve the hostname, along with
	// the URL for the query that is about to be sent. The root resource will be the top-level parent resource's name.
	// Some HostnameResolver implementations will choose to ignore this parameter and resolve hostnames using a
	// different strategy.
	ResolveHostnameAndContextForQuery(rootResource string, query *url.URL) (*url.URL, error)
}

type IllegalEnumConstant

type IllegalEnumConstant struct {
	Enum     string
	Constant int
}

func (*IllegalEnumConstant) Error

func (i *IllegalEnumConstant) Error() string

type IllegalPartialUpdateError

type IllegalPartialUpdateError struct {
	Message    string
	RecordType string
	Field      string
}

IllegalPartialUpdateError is returned by PartialUpdateFieldChecker a partial update struct defines an illegal operation, such as deleting and setting the same field.

func (*IllegalPartialUpdateError) Error

func (c *IllegalPartialUpdateError) Error() string

type LoggingRoundTripper

type LoggingRoundTripper struct {
	http.RoundTripper
	Logger logger
}

LoggingRoundTripper is an http.RoundTripper that wraps a backing http.RoundTripper and logs all outbound queries (method, URL, headers and body) to the given logger

func (*LoggingRoundTripper) RoundTrip

func (l *LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type Method

type Method int

func GetMethodFromContext

func GetMethodFromContext(ctx context.Context) Method

func (Method) String

func (i Method) String() string

type PartialUpdateFieldChecker

type PartialUpdateFieldChecker struct {
	RecordType string
	HasDeletes bool
	HasSets    bool
}

func (*PartialUpdateFieldChecker) CheckField

func (c *PartialUpdateFieldChecker) CheckField(
	checker restlicodec.KeyChecker,
	fieldName string,
	isDeleteSet bool,
	isSetSet bool,
	isPartialUpdateSet bool,
) error

type QueryParamsEncoder

type QueryParamsEncoder interface {
	EncodeQueryParams() (string, error)
}

type QueryParamsString

type QueryParamsString string

func (QueryParamsString) EncodeQueryParams

func (q QueryParamsString) EncodeQueryParams() (string, error)

type RequestContext

type RequestContext struct {
	Request         *http.Request
	ResponseHeaders http.Header
	ResponseStatus  int
}

func (*RequestContext) RequestPath added in v1.1.0

func (c *RequestContext) RequestPath() string

type ResourcePath

type ResourcePath interface {
	RootResource() string
	ResourcePath() (path string, err error)
}

type ResourcePathSegment

type ResourcePathSegment struct {
	// contains filtered or unexported fields
}

func GetResourcePathSegmentsFromContext

func GetResourcePathSegmentsFromContext(ctx context.Context) []ResourcePathSegment

func NewResourcePathSegment

func NewResourcePathSegment(name string, isCollection bool) ResourcePathSegment

type ResourcePathString

type ResourcePathString string

func (ResourcePathString) ResourcePath

func (s ResourcePathString) ResourcePath() (string, error)

func (ResourcePathString) RootResource

func (s ResourcePathString) RootResource() string

type ResourcePathUnmarshaler

type ResourcePathUnmarshaler[T any] interface {
	NewInstance() T
	UnmarshalResourcePath(segments []restlicodec.Reader) error
}

type Server

type Server interface {
	// AddToMux adds a http.Handler for each root resource registered against this Server. Note that resources
	// registered to this Server after AddToMux is called will not be reflected.
	AddToMux(mux *http.ServeMux)
	// Handler returns a raw http.Handler backed by a copy of this sever. Note that resources registered to this Server
	// after Handler will not be reflected. This is not meant to be used in conjunction with a http.ServeMux, but
	// instead with methods like http.ListenAndServe or http.ListenAndServeTLS
	Handler() http.Handler
	// contains filtered or unexported methods
}

func NewPrefixedServer

func NewPrefixedServer(prefix string, filters ...Filter) Server

func NewServer

func NewServer(filters ...Filter) Server

type SimpleHostnameResolver

type SimpleHostnameResolver struct {
	Hostname *url.URL
}

func (*SimpleHostnameResolver) ResolveHostnameAndContextForQuery

func (s *SimpleHostnameResolver) ResolveHostnameAndContextForQuery(string, *url.URL) (*url.URL, error)

type SliceBatchQueryParams

type SliceBatchQueryParams[T any] struct{}

func (*SliceBatchQueryParams[T]) DecodeQueryParams

func (s *SliceBatchQueryParams[T]) DecodeQueryParams(reader restlicodec.QueryParamsReader) (ids []T, err error)

func (*SliceBatchQueryParams[T]) NewInstance

func (s *SliceBatchQueryParams[T]) NewInstance() *SliceBatchQueryParams[T]

type UnexpectedStatusCodeError

type UnexpectedStatusCodeError struct {
	// The raw response that of the failed call. Note that to ensure that the connection can be reused, the Body
	// of the response is fully read into ResponseBody then closed
	Response     *http.Response
	ResponseBody []byte
}

UnexpectedStatusCodeError is returned by the Do* methods when the target rest.li service responded with non-2xx code but did not set the expected X-RestLi-Error-Response header.

func (*UnexpectedStatusCodeError) Error

func (u *UnexpectedStatusCodeError) Error() string

type UnknownEnumValue

type UnknownEnumValue struct {
	Enum  string
	Value string
}

func (*UnknownEnumValue) Error

func (u *UnknownEnumValue) Error() string

type UnsupportedRestLiProtocolVersion

type UnsupportedRestLiProtocolVersion struct {
	ReturnedVersion string
}

UnsupportedRestLiProtocolVersion is returned when the server returns a version other than the requested one, which is always ProtocolVersion.

func (*UnsupportedRestLiProtocolVersion) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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