server

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeGetRequest

func DecodeGetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error)

DecodeGetRequest returns a decoder for requests sent to the rating Get endpoint.

func DecodeUpdateRequest

func DecodeUpdateRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error)

DecodeUpdateRequest returns a decoder for requests sent to the rating Update endpoint.

func EncodeGetError

func EncodeGetError(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, formatter func(err error) goahttp.Statuser) func(context.Context, http.ResponseWriter, error) error

EncodeGetError returns an encoder for errors returned by the Get rating endpoint.

func EncodeGetResponse

func EncodeGetResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeGetResponse returns an encoder for responses returned by the rating Get endpoint.

func EncodeUpdateError

func EncodeUpdateError(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, formatter func(err error) goahttp.Statuser) func(context.Context, http.ResponseWriter, error) error

EncodeUpdateError returns an encoder for errors returned by the Update rating endpoint.

func EncodeUpdateResponse

func EncodeUpdateResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeUpdateResponse returns an encoder for responses returned by the rating Update endpoint.

func GetRatingPath

func GetRatingPath(id uint) string

GetRatingPath returns the URL path to the rating service Get HTTP endpoint.

func HandleRatingOrigin added in v1.8.0

func HandleRatingOrigin(h http.Handler) http.Handler

HandleRatingOrigin applies the CORS response headers corresponding to the origin for the service rating.

func Mount

func Mount(mux goahttp.Muxer, h *Server)

Mount configures the mux to serve the rating endpoints.

func MountCORSHandler

func MountCORSHandler(mux goahttp.Muxer, h http.Handler)

MountCORSHandler configures the mux to serve the CORS endpoints for the service rating.

func MountGetHandler

func MountGetHandler(mux goahttp.Muxer, h http.Handler)

MountGetHandler configures the mux to serve the "rating" service "Get" endpoint.

func MountUpdateHandler

func MountUpdateHandler(mux goahttp.Muxer, h http.Handler)

MountUpdateHandler configures the mux to serve the "rating" service "Update" endpoint.

func NewCORSHandler

func NewCORSHandler() http.Handler

NewCORSHandler creates a HTTP handler which returns a simple 200 response.

func NewGetHandler

func NewGetHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewGetHandler creates a HTTP handler which loads the HTTP request and calls the "rating" service "Get" endpoint.

func NewGetPayload

func NewGetPayload(id uint, token string) *rating.GetPayload

NewGetPayload builds a rating service Get endpoint payload.

func NewUpdateHandler

func NewUpdateHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewUpdateHandler creates a HTTP handler which loads the HTTP request and calls the "rating" service "Update" endpoint.

func NewUpdatePayload

func NewUpdatePayload(body *UpdateRequestBody, id uint, token string) *rating.UpdatePayload

NewUpdatePayload builds a rating service Update endpoint payload.

func UpdateRatingPath

func UpdateRatingPath(id uint) string

UpdateRatingPath returns the URL path to the rating service Update HTTP endpoint.

func ValidateUpdateRequestBody

func ValidateUpdateRequestBody(body *UpdateRequestBody) (err error)

ValidateUpdateRequestBody runs the validations defined on UpdateRequestBody

Types

type ErrorNamer

type ErrorNamer interface {
	ErrorName() string
}

ErrorNamer is an interface implemented by generated error structs that exposes the name of the error as defined in the design.

type GetInternalErrorResponseBody

type GetInternalErrorResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

GetInternalErrorResponseBody is the type of the "rating" service "Get" endpoint HTTP response body for the "internal-error" error.

func NewGetInternalErrorResponseBody

func NewGetInternalErrorResponseBody(res *goa.ServiceError) *GetInternalErrorResponseBody

NewGetInternalErrorResponseBody builds the HTTP response body from the result of the "Get" endpoint of the "rating" service.

type GetInvalidScopesResponseBody

type GetInvalidScopesResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

GetInvalidScopesResponseBody is the type of the "rating" service "Get" endpoint HTTP response body for the "invalid-scopes" error.

func NewGetInvalidScopesResponseBody

func NewGetInvalidScopesResponseBody(res *goa.ServiceError) *GetInvalidScopesResponseBody

NewGetInvalidScopesResponseBody builds the HTTP response body from the result of the "Get" endpoint of the "rating" service.

type GetInvalidTokenResponseBody

type GetInvalidTokenResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

GetInvalidTokenResponseBody is the type of the "rating" service "Get" endpoint HTTP response body for the "invalid-token" error.

func NewGetInvalidTokenResponseBody

func NewGetInvalidTokenResponseBody(res *goa.ServiceError) *GetInvalidTokenResponseBody

NewGetInvalidTokenResponseBody builds the HTTP response body from the result of the "Get" endpoint of the "rating" service.

type GetNotFoundResponseBody

type GetNotFoundResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

GetNotFoundResponseBody is the type of the "rating" service "Get" endpoint HTTP response body for the "not-found" error.

func NewGetNotFoundResponseBody

func NewGetNotFoundResponseBody(res *goa.ServiceError) *GetNotFoundResponseBody

NewGetNotFoundResponseBody builds the HTTP response body from the result of the "Get" endpoint of the "rating" service.

type GetResponseBody

type GetResponseBody struct {
	// User rating for resource
	Rating int `form:"rating" json:"rating" xml:"rating"`
}

GetResponseBody is the type of the "rating" service "Get" endpoint HTTP response body.

func NewGetResponseBody

func NewGetResponseBody(res *rating.GetResult) *GetResponseBody

NewGetResponseBody builds the HTTP response body from the result of the "Get" endpoint of the "rating" service.

type MountPoint

type MountPoint struct {
	// Method is the name of the service method served by the mounted HTTP handler.
	Method string
	// Verb is the HTTP method used to match requests to the mounted handler.
	Verb string
	// Pattern is the HTTP request path pattern used to match requests to the
	// mounted handler.
	Pattern string
}

MountPoint holds information about the mounted endpoints.

type Server

type Server struct {
	Mounts []*MountPoint
	Get    http.Handler
	Update http.Handler
	CORS   http.Handler
}

Server lists the rating service endpoint HTTP handlers.

func New

func New(
	e *rating.Endpoints,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) *Server

New instantiates HTTP handlers for all the rating service endpoints using the provided encoder and decoder. The handlers are mounted on the given mux using the HTTP verb and path defined in the design. errhandler is called whenever a response fails to be encoded. formatter is used to format errors returned by the service methods prior to encoding. Both errhandler and formatter are optional and can be nil.

func (*Server) Mount added in v1.8.0

func (s *Server) Mount(mux goahttp.Muxer)

Mount configures the mux to serve the rating endpoints.

func (*Server) Service

func (s *Server) Service() string

Service returns the name of the service served.

func (*Server) Use

func (s *Server) Use(m func(http.Handler) http.Handler)

Use wraps the server handlers with the given middleware.

type UpdateInternalErrorResponseBody

type UpdateInternalErrorResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

UpdateInternalErrorResponseBody is the type of the "rating" service "Update" endpoint HTTP response body for the "internal-error" error.

func NewUpdateInternalErrorResponseBody

func NewUpdateInternalErrorResponseBody(res *goa.ServiceError) *UpdateInternalErrorResponseBody

NewUpdateInternalErrorResponseBody builds the HTTP response body from the result of the "Update" endpoint of the "rating" service.

type UpdateInvalidScopesResponseBody

type UpdateInvalidScopesResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

UpdateInvalidScopesResponseBody is the type of the "rating" service "Update" endpoint HTTP response body for the "invalid-scopes" error.

func NewUpdateInvalidScopesResponseBody

func NewUpdateInvalidScopesResponseBody(res *goa.ServiceError) *UpdateInvalidScopesResponseBody

NewUpdateInvalidScopesResponseBody builds the HTTP response body from the result of the "Update" endpoint of the "rating" service.

type UpdateInvalidTokenResponseBody

type UpdateInvalidTokenResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

UpdateInvalidTokenResponseBody is the type of the "rating" service "Update" endpoint HTTP response body for the "invalid-token" error.

func NewUpdateInvalidTokenResponseBody

func NewUpdateInvalidTokenResponseBody(res *goa.ServiceError) *UpdateInvalidTokenResponseBody

NewUpdateInvalidTokenResponseBody builds the HTTP response body from the result of the "Update" endpoint of the "rating" service.

type UpdateNotFoundResponseBody

type UpdateNotFoundResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

UpdateNotFoundResponseBody is the type of the "rating" service "Update" endpoint HTTP response body for the "not-found" error.

func NewUpdateNotFoundResponseBody

func NewUpdateNotFoundResponseBody(res *goa.ServiceError) *UpdateNotFoundResponseBody

NewUpdateNotFoundResponseBody builds the HTTP response body from the result of the "Update" endpoint of the "rating" service.

type UpdateRequestBody

type UpdateRequestBody struct {
	// User rating for resource
	Rating *uint `form:"rating,omitempty" json:"rating,omitempty" xml:"rating,omitempty"`
}

UpdateRequestBody is the type of the "rating" service "Update" endpoint HTTP request body.

Jump to

Keyboard shortcuts

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