server

package
v2.1.3+incompatible Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePickRequest

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

DecodePickRequest returns a decoder for requests sent to the sommelier pick endpoint.

func EncodePickError

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

EncodePickError returns an encoder for errors returned by the pick sommelier endpoint.

func EncodePickResponse

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

EncodePickResponse returns an encoder for responses returned by the sommelier pick endpoint.

func Mount

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

Mount configures the mux to serve the sommelier endpoints.

func MountPickHandler

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

MountPickHandler configures the mux to serve the "sommelier" service "pick" endpoint.

func NewPickCriteria

func NewPickCriteria(body *PickRequestBody) *sommelier.Criteria

NewPickCriteria builds a sommelier service pick endpoint payload.

func NewPickHandler

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

NewPickHandler creates a HTTP handler which loads the HTTP request and calls the "sommelier" service "pick" endpoint.

func PickSommelierPath

func PickSommelierPath() string

PickSommelierPath returns the URL path to the sommelier service pick HTTP endpoint.

Types

type ComponentResponse

type ComponentResponse struct {
	// Grape varietal
	Varietal string `form:"varietal" json:"varietal" xml:"varietal"`
	// Percentage of varietal in wine
	Percentage *uint32 `form:"percentage,omitempty" json:"percentage,omitempty" xml:"percentage,omitempty"`
}

ComponentResponse is used to define fields on response body 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 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 PickNoCriteriaResponseBody

type PickNoCriteriaResponseBody string

PickNoCriteriaResponseBody is the type of the "sommelier" service "pick" endpoint HTTP response body for the "no_criteria" error.

func NewPickNoCriteriaResponseBody

func NewPickNoCriteriaResponseBody(res sommelier.NoCriteria) PickNoCriteriaResponseBody

NewPickNoCriteriaResponseBody builds the HTTP response body from the result of the "pick" endpoint of the "sommelier" service.

type PickNoMatchResponseBody

type PickNoMatchResponseBody string

PickNoMatchResponseBody is the type of the "sommelier" service "pick" endpoint HTTP response body for the "no_match" error.

func NewPickNoMatchResponseBody

func NewPickNoMatchResponseBody(res sommelier.NoMatch) PickNoMatchResponseBody

NewPickNoMatchResponseBody builds the HTTP response body from the result of the "pick" endpoint of the "sommelier" service.

type PickRequestBody

type PickRequestBody struct {
	// Name of bottle to pick
	Name *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
	// Varietals in preference order
	Varietal []string `form:"varietal,omitempty" json:"varietal,omitempty" xml:"varietal,omitempty"`
	// Winery of bottle to pick
	Winery *string `form:"winery,omitempty" json:"winery,omitempty" xml:"winery,omitempty"`
}

PickRequestBody is the type of the "sommelier" service "pick" endpoint HTTP request body.

type Server

type Server struct {
	Mounts []*MountPoint
	Pick   http.Handler
}

Server lists the sommelier service endpoint HTTP handlers.

func New

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

type StoredBottleResponse

type StoredBottleResponse struct {
	// ID is the unique id of the bottle.
	ID string `form:"id" json:"id" xml:"id"`
	// Name of bottle
	Name string `form:"name" json:"name" xml:"name"`
	// Winery that produces wine
	Winery *WineryResponseTiny `form:"winery" json:"winery" xml:"winery"`
	// Vintage of bottle
	Vintage uint32 `form:"vintage" json:"vintage" xml:"vintage"`
	// Composition is the list of grape varietals and associated percentage.
	Composition []*ComponentResponse `form:"composition,omitempty" json:"composition,omitempty" xml:"composition,omitempty"`
	// Description of bottle
	Description *string `form:"description,omitempty" json:"description,omitempty" xml:"description,omitempty"`
	// Rating of bottle from 1 (worst) to 5 (best)
	Rating *uint32 `form:"rating,omitempty" json:"rating,omitempty" xml:"rating,omitempty"`
}

StoredBottleResponse is used to define fields on response body types.

type StoredBottleResponseCollection

type StoredBottleResponseCollection []*StoredBottleResponse

StoredBottleResponseCollection is the type of the "sommelier" service "pick" endpoint HTTP response body.

func NewStoredBottleResponseCollection

func NewStoredBottleResponseCollection(res sommelierviews.StoredBottleCollectionView) StoredBottleResponseCollection

NewStoredBottleResponseCollection builds the HTTP response body from the result of the "pick" endpoint of the "sommelier" service.

type WineryResponseTiny

type WineryResponseTiny struct {
	// Name of winery
	Name string `form:"name" json:"name" xml:"name"`
}

WineryResponseTiny is used to define fields on response body types.

Jump to

Keyboard shortcuts

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