server

package
v0.0.0-...-dca2783 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeEmailRequest

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

DecodeEmailRequest returns a decoder for requests sent to the test email endpoint.

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 test get endpoint.

func EmailTestPath

func EmailTestPath() string

EmailTestPath returns the URL path to the test service email HTTP endpoint.

func EncodeEmailError

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

EncodeEmailError returns an encoder for errors returned by the email test endpoint.

func EncodeEmailResponse

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

EncodeEmailResponse returns an encoder for responses returned by the test email endpoint.

func EncodeErrorError

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

EncodeErrorError returns an encoder for errors returned by the error test endpoint.

func EncodeErrorResponse

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

EncodeErrorResponse returns an encoder for responses returned by the test error 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 test 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 test get endpoint.

func ErrorTestPath

func ErrorTestPath() string

ErrorTestPath returns the URL path to the test service error HTTP endpoint.

func GetTestPath

func GetTestPath(id int64) string

GetTestPath returns the URL path to the test service get HTTP endpoint.

func Mount

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

Mount configures the mux to serve the test endpoints.

func MountCORSHandler

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

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

func MountEmailHandler

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

MountEmailHandler configures the mux to serve the "test" service "email" endpoint.

func MountErrorHandler

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

MountErrorHandler configures the mux to serve the "test" service "error" endpoint.

func MountGetHandler

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

MountGetHandler configures the mux to serve the "test" service "get" endpoint.

func NewCORSHandler

func NewCORSHandler() http.Handler

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

func NewEmailHandler

func NewEmailHandler(
	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

NewEmailHandler creates a HTTP handler which loads the HTTP request and calls the "test" service "email" endpoint.

func NewEmailPayload

func NewEmailPayload(address string, auth string) *test.EmailPayload

NewEmailPayload builds a test service email endpoint payload.

func NewErrorHandler

func NewErrorHandler(
	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

NewErrorHandler creates a HTTP handler which loads the HTTP request and calls the "test" service "error" endpoint.

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 "test" service "get" endpoint.

func NewGetPayload

func NewGetPayload(id int64) *test.GetPayload

NewGetPayload builds a test service get endpoint payload.

Types

type EmailBadRequestResponseBody

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

EmailBadRequestResponseBody is the type of the "test" service "email" endpoint HTTP response body for the "bad-request" error.

func NewEmailBadRequestResponseBody

func NewEmailBadRequestResponseBody(res *goa.ServiceError) *EmailBadRequestResponseBody

NewEmailBadRequestResponseBody builds the HTTP response body from the result of the "email" endpoint of the "test" service.

type EmailForbiddenResponseBody

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

EmailForbiddenResponseBody is the type of the "test" service "email" endpoint HTTP response body for the "forbidden" error.

func NewEmailForbiddenResponseBody

func NewEmailForbiddenResponseBody(res *goa.ServiceError) *EmailForbiddenResponseBody

NewEmailForbiddenResponseBody builds the HTTP response body from the result of the "email" endpoint of the "test" service.

type EmailNotFoundResponseBody

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

EmailNotFoundResponseBody is the type of the "test" service "email" endpoint HTTP response body for the "not-found" error.

func NewEmailNotFoundResponseBody

func NewEmailNotFoundResponseBody(res *goa.ServiceError) *EmailNotFoundResponseBody

NewEmailNotFoundResponseBody builds the HTTP response body from the result of the "email" endpoint of the "test" service.

type EmailUnauthorizedResponseBody

type EmailUnauthorizedResponseBody string

EmailUnauthorizedResponseBody is the type of the "test" service "email" endpoint HTTP response body for the "unauthorized" error.

func NewEmailUnauthorizedResponseBody

func NewEmailUnauthorizedResponseBody(res test.Unauthorized) EmailUnauthorizedResponseBody

NewEmailUnauthorizedResponseBody builds the HTTP response body from the result of the "email" endpoint of the "test" service.

type ErrorBadRequestResponseBody

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

ErrorBadRequestResponseBody is the type of the "test" service "error" endpoint HTTP response body for the "bad-request" error.

func NewErrorBadRequestResponseBody

func NewErrorBadRequestResponseBody(res *goa.ServiceError) *ErrorBadRequestResponseBody

NewErrorBadRequestResponseBody builds the HTTP response body from the result of the "error" endpoint of the "test" service.

type ErrorForbiddenResponseBody

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

ErrorForbiddenResponseBody is the type of the "test" service "error" endpoint HTTP response body for the "forbidden" error.

func NewErrorForbiddenResponseBody

func NewErrorForbiddenResponseBody(res *goa.ServiceError) *ErrorForbiddenResponseBody

NewErrorForbiddenResponseBody builds the HTTP response body from the result of the "error" endpoint of the "test" service.

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 ErrorNotFoundResponseBody

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

ErrorNotFoundResponseBody is the type of the "test" service "error" endpoint HTTP response body for the "not-found" error.

func NewErrorNotFoundResponseBody

func NewErrorNotFoundResponseBody(res *goa.ServiceError) *ErrorNotFoundResponseBody

NewErrorNotFoundResponseBody builds the HTTP response body from the result of the "error" endpoint of the "test" service.

type ErrorUnauthorizedResponseBody

type ErrorUnauthorizedResponseBody string

ErrorUnauthorizedResponseBody is the type of the "test" service "error" endpoint HTTP response body for the "unauthorized" error.

func NewErrorUnauthorizedResponseBody

func NewErrorUnauthorizedResponseBody(res test.Unauthorized) ErrorUnauthorizedResponseBody

NewErrorUnauthorizedResponseBody builds the HTTP response body from the result of the "error" endpoint of the "test" service.

type GetBadRequestResponseBody

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

GetBadRequestResponseBody is the type of the "test" service "get" endpoint HTTP response body for the "bad-request" error.

func NewGetBadRequestResponseBody

func NewGetBadRequestResponseBody(res *goa.ServiceError) *GetBadRequestResponseBody

NewGetBadRequestResponseBody builds the HTTP response body from the result of the "get" endpoint of the "test" service.

type GetForbiddenResponseBody

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

GetForbiddenResponseBody is the type of the "test" service "get" endpoint HTTP response body for the "forbidden" error.

func NewGetForbiddenResponseBody

func NewGetForbiddenResponseBody(res *goa.ServiceError) *GetForbiddenResponseBody

NewGetForbiddenResponseBody builds the HTTP response body from the result of the "get" endpoint of the "test" 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 "test" 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 "test" service.

type GetUnauthorizedResponseBody

type GetUnauthorizedResponseBody string

GetUnauthorizedResponseBody is the type of the "test" service "get" endpoint HTTP response body for the "unauthorized" error.

func NewGetUnauthorizedResponseBody

func NewGetUnauthorizedResponseBody(res test.Unauthorized) GetUnauthorizedResponseBody

NewGetUnauthorizedResponseBody builds the HTTP response body from the result of the "get" endpoint of the "test" 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
	Error  http.Handler
	Email  http.Handler
	CORS   http.Handler
}

Server lists the test service endpoint HTTP handlers.

func New

func New(
	e *test.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 test 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) 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