server

package
v0.0.0-...-a37e7a8 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeDivideRequest

func DecodeDivideRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (any, error)

DecodeDivideRequest returns a decoder for requests sent to the calc divide endpoint.

func DivideCalcPath

func DivideCalcPath() string

DivideCalcPath returns the URL path to the calc service divide HTTP endpoint.

func EncodeDivideError

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

EncodeDivideError returns an encoder for errors returned by the divide calc endpoint.

func EncodeDivideResponse

func EncodeDivideResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error

EncodeDivideResponse returns an encoder for responses returned by the calc divide endpoint.

func Mount

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

Mount configures the mux to serve the calc endpoints.

func MountDivideHandler

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

MountDivideHandler configures the mux to serve the "calc" service "divide" endpoint.

func NewDivideHandler

func NewDivideHandler(
	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(ctx context.Context, err error) goahttp.Statuser,
) http.Handler

NewDivideHandler creates a HTTP handler which loads the HTTP request and calls the "calc" service "divide" endpoint.

func NewDividePayload

func NewDividePayload(body *DivideRequestBody) *calc.DividePayload

NewDividePayload builds a calc service divide endpoint payload.

func ValidateDivideRequestBody

func ValidateDivideRequestBody(body *DivideRequestBody) (err error)

ValidateDivideRequestBody runs the validations defined on DivideRequestBody

Types

type DivideDivByZeroResponseBody

type DivideDivByZeroResponseBody struct {
	// division by zero leads to infinity.
	Message string `form:"message" json:"message" xml:"message"`
}

DivideDivByZeroResponseBody is the type of the "calc" service "divide" endpoint HTTP response body for the "div_by_zero" error.

func NewDivideDivByZeroResponseBody

func NewDivideDivByZeroResponseBody(res *calc.DivByZero) *DivideDivByZeroResponseBody

NewDivideDivByZeroResponseBody builds the HTTP response body from the result of the "divide" endpoint of the "calc" service.

type DivideRequestBody

type DivideRequestBody struct {
	Dividend *int `form:"dividend,omitempty" json:"dividend,omitempty" xml:"dividend,omitempty"`
	Divisor  *int `form:"divisor,omitempty" json:"divisor,omitempty" xml:"divisor,omitempty"`
}

DivideRequestBody is the type of the "calc" service "divide" endpoint HTTP request body.

type DivideResponseBody

type DivideResponseBody struct {
	Quotient int `form:"quotient" json:"quotient" xml:"quotient"`
	Reminder int `form:"reminder" json:"reminder" xml:"reminder"`
}

DivideResponseBody is the type of the "calc" service "divide" endpoint HTTP response body.

func NewDivideResponseBody

func NewDivideResponseBody(res *calc.DivideResult) *DivideResponseBody

NewDivideResponseBody builds the HTTP response body from the result of the "divide" endpoint of the "calc" service.

type DivideTimeoutResponseBody

type DivideTimeoutResponseBody 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"`
}

DivideTimeoutResponseBody is the type of the "calc" service "divide" endpoint HTTP response body for the "timeout" error.

func NewDivideTimeoutResponseBody

func NewDivideTimeoutResponseBody(res *goa.ServiceError) *DivideTimeoutResponseBody

NewDivideTimeoutResponseBody builds the HTTP response body from the result of the "divide" endpoint of the "calc" 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
	Divide http.Handler
}

Server lists the calc service endpoint HTTP handlers.

func New

func New(
	e *calc.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(ctx context.Context, err error) goahttp.Statuser,
) *Server

New instantiates HTTP handlers for all the calc 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) MethodNames

func (s *Server) MethodNames() []string

MethodNames returns the methods served.

func (*Server) Mount

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

Mount configures the mux to serve the calc 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.

Jump to

Keyboard shortcuts

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