server

package
v0.0.0-...-f99326c Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBookLibrarianPath

func CreateBookLibrarianPath() string

CreateBookLibrarianPath returns the URL path to the librarian service create-book HTTP endpoint.

func DecodeCreateBookRequest

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

DecodeCreateBookRequest returns a decoder for requests sent to the librarian create-book endpoint.

func DecodeDeleteBookRequest

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

DecodeDeleteBookRequest returns a decoder for requests sent to the librarian delete-book endpoint.

func DecodeGetBookRequest

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

DecodeGetBookRequest returns a decoder for requests sent to the librarian get-book endpoint.

func DecodeGetBooksRequest

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

DecodeGetBooksRequest returns a decoder for requests sent to the librarian get-books endpoint.

func DecodeUpdateBookRequest

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

DecodeUpdateBookRequest returns a decoder for requests sent to the librarian update-book endpoint.

func DeleteBookLibrarianPath

func DeleteBookLibrarianPath(id int) string

DeleteBookLibrarianPath returns the URL path to the librarian service delete-book HTTP endpoint.

func EncodeCreateBookError

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

EncodeCreateBookError returns an encoder for errors returned by the create-book librarian endpoint.

func EncodeCreateBookResponse

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

EncodeCreateBookResponse returns an encoder for responses returned by the librarian create-book endpoint.

func EncodeDeleteBookResponse

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

EncodeDeleteBookResponse returns an encoder for responses returned by the librarian delete-book endpoint.

func EncodeGetBookError

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

EncodeGetBookError returns an encoder for errors returned by the get-book librarian endpoint.

func EncodeGetBookResponse

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

EncodeGetBookResponse returns an encoder for responses returned by the librarian get-book endpoint.

func EncodeGetBooksResponse

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

EncodeGetBooksResponse returns an encoder for responses returned by the librarian get-books endpoint.

func EncodeUpdateBookResponse

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

EncodeUpdateBookResponse returns an encoder for responses returned by the librarian update-book endpoint.

func GetBookLibrarianPath

func GetBookLibrarianPath(id int) string

GetBookLibrarianPath returns the URL path to the librarian service get-book HTTP endpoint.

func GetBooksLibrarianPath

func GetBooksLibrarianPath(skip int, take int) string

GetBooksLibrarianPath returns the URL path to the librarian service get-books HTTP endpoint.

func Mount

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

Mount configures the mux to serve the librarian endpoints.

func MountCreateBookHandler

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

MountCreateBookHandler configures the mux to serve the "librarian" service "create-book" endpoint.

func MountDeleteBookHandler

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

MountDeleteBookHandler configures the mux to serve the "librarian" service "delete-book" endpoint.

func MountGenHTTPOpenapiJSON

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

MountGenHTTPOpenapiJSON configures the mux to serve GET request made to "/openapi.json".

func MountGetBookHandler

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

MountGetBookHandler configures the mux to serve the "librarian" service "get-book" endpoint.

func MountGetBooksHandler

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

MountGetBooksHandler configures the mux to serve the "librarian" service "get-books" endpoint.

func MountUpdateBookHandler

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

MountUpdateBookHandler configures the mux to serve the "librarian" service "update-book" endpoint.

func NewCreateBookHandler

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

NewCreateBookHandler creates a HTTP handler which loads the HTTP request and calls the "librarian" service "create-book" endpoint.

func NewCreateBookPayload

func NewCreateBookPayload(body *CreateBookRequestBody) *librarian.CreateBookPayload

NewCreateBookPayload builds a librarian service create-book endpoint payload.

func NewDeleteBookHandler

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

NewDeleteBookHandler creates a HTTP handler which loads the HTTP request and calls the "librarian" service "delete-book" endpoint.

func NewDeleteBookPayload

func NewDeleteBookPayload(id int) *librarian.DeleteBookPayload

NewDeleteBookPayload builds a librarian service delete-book endpoint payload.

func NewGetBookHandler

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

NewGetBookHandler creates a HTTP handler which loads the HTTP request and calls the "librarian" service "get-book" endpoint.

func NewGetBookPayload

func NewGetBookPayload(id int) *librarian.GetBookPayload

NewGetBookPayload builds a librarian service get-book endpoint payload.

func NewGetBooksHandler

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

NewGetBooksHandler creates a HTTP handler which loads the HTTP request and calls the "librarian" service "get-books" endpoint.

func NewGetBooksPayload

func NewGetBooksPayload(skip int, take int) *librarian.GetBooksPayload

NewGetBooksPayload builds a librarian service get-books endpoint payload.

func NewUpdateBookHandler

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

NewUpdateBookHandler creates a HTTP handler which loads the HTTP request and calls the "librarian" service "update-book" endpoint.

func NewUpdateBookPayload

func NewUpdateBookPayload(body *UpdateBookRequestBody) *librarian.UpdateBookPayload

NewUpdateBookPayload builds a librarian service update-book endpoint payload.

func UpdateBookLibrarianPath

func UpdateBookLibrarianPath() string

UpdateBookLibrarianPath returns the URL path to the librarian service update-book HTTP endpoint.

func ValidateCreateBookRequestBody

func ValidateCreateBookRequestBody(body *CreateBookRequestBody) (err error)

ValidateCreateBookRequestBody runs the validations defined on Create-BookRequestBody

func ValidateUpdateBookRequestBody

func ValidateUpdateBookRequestBody(body *UpdateBookRequestBody) (err error)

ValidateUpdateBookRequestBody runs the validations defined on Update-BookRequestBody

Types

type CreateBookBadRequestResponseBody

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

CreateBookBadRequestResponseBody is the type of the "librarian" service "create-book" endpoint HTTP response body for the "bad_request" error.

func NewCreateBookBadRequestResponseBody

func NewCreateBookBadRequestResponseBody(res *goa.ServiceError) *CreateBookBadRequestResponseBody

NewCreateBookBadRequestResponseBody builds the HTTP response body from the result of the "create-book" endpoint of the "librarian" service.

type CreateBookInternalServerErrorResponseBody

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

CreateBookInternalServerErrorResponseBody is the type of the "librarian" service "create-book" endpoint HTTP response body for the "internal_server_error" error.

func NewCreateBookInternalServerErrorResponseBody

func NewCreateBookInternalServerErrorResponseBody(res *goa.ServiceError) *CreateBookInternalServerErrorResponseBody

NewCreateBookInternalServerErrorResponseBody builds the HTTP response body from the result of the "create-book" endpoint of the "librarian" service.

type CreateBookNotFoundResponseBody

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

CreateBookNotFoundResponseBody is the type of the "librarian" service "create-book" endpoint HTTP response body for the "not_found" error.

func NewCreateBookNotFoundResponseBody

func NewCreateBookNotFoundResponseBody(res *goa.ServiceError) *CreateBookNotFoundResponseBody

NewCreateBookNotFoundResponseBody builds the HTTP response body from the result of the "create-book" endpoint of the "librarian" service.

type CreateBookRequestBody

type CreateBookRequestBody struct {
	// The title of the book.
	Title *string `form:"title,omitempty" json:"title,omitempty" xml:"title,omitempty"`
	// The author of the book.
	Author *string `form:"author,omitempty" json:"author,omitempty" xml:"author,omitempty"`
	// The URL to the cover image.
	BookCover *string `form:"book_cover,omitempty" json:"book_cover,omitempty" xml:"book_cover,omitempty"`
	// The date at which the book was published.
	PublishedAt *string `form:"published_at,omitempty" json:"published_at,omitempty" xml:"published_at,omitempty"`
}

CreateBookRequestBody is the type of the "librarian" service "create-book" endpoint HTTP request body.

type CreateBookResponseBody

type CreateBookResponseBody struct {
	// The unique id of the book.
	ID int `form:"id" json:"id" xml:"id"`
	// The title of the book.
	Title string `form:"title" json:"title" xml:"title"`
	// The author of the book.
	Author string `form:"author" json:"author" xml:"author"`
	// The cover image of the book.
	BookCover string `form:"book_cover" json:"book_cover" xml:"book_cover"`
	// The date at which the book was published.
	PublishedAt string `form:"published_at" json:"published_at" xml:"published_at"`
}

CreateBookResponseBody is the type of the "librarian" service "create-book" endpoint HTTP response body.

func NewCreateBookResponseBody

func NewCreateBookResponseBody(res *librarianviews.CreatebookresponseView) *CreateBookResponseBody

NewCreateBookResponseBody builds the HTTP response body from the result of the "create-book" endpoint of the "librarian" service.

type GetBookInternalServerErrorResponseBody

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

GetBookInternalServerErrorResponseBody is the type of the "librarian" service "get-book" endpoint HTTP response body for the "internal_server_error" error.

func NewGetBookInternalServerErrorResponseBody

func NewGetBookInternalServerErrorResponseBody(res *goa.ServiceError) *GetBookInternalServerErrorResponseBody

NewGetBookInternalServerErrorResponseBody builds the HTTP response body from the result of the "get-book" endpoint of the "librarian" service.

type GetBookNotFoundResponseBody

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

GetBookNotFoundResponseBody is the type of the "librarian" service "get-book" endpoint HTTP response body for the "not_found" error.

func NewGetBookNotFoundResponseBody

func NewGetBookNotFoundResponseBody(res *goa.ServiceError) *GetBookNotFoundResponseBody

NewGetBookNotFoundResponseBody builds the HTTP response body from the result of the "get-book" endpoint of the "librarian" service.

type GetBookResponseBody

type GetBookResponseBody struct {
	// The unique id of the book.
	ID int `form:"id" json:"id" xml:"id"`
	// The title of the book.
	Title string `form:"title" json:"title" xml:"title"`
	// The author of the book.
	Author string `form:"author" json:"author" xml:"author"`
	// The cover image of the book.
	BookCover string `form:"book_cover" json:"book_cover" xml:"book_cover"`
	// The date at which the book was published.
	PublishedAt string `form:"published_at" json:"published_at" xml:"published_at"`
}

GetBookResponseBody is the type of the "librarian" service "get-book" endpoint HTTP response body.

func NewGetBookResponseBody

func NewGetBookResponseBody(res *librarianviews.GetbookresponseView) *GetBookResponseBody

NewGetBookResponseBody builds the HTTP response body from the result of the "get-book" endpoint of the "librarian" service.

type GetBooksResponseBody

type GetBooksResponseBody struct {
	// List of paginated books.
	Books ResultbookResponseBodyCollection `form:"books,omitempty" json:"books,omitempty" xml:"books,omitempty"`
}

GetBooksResponseBody is the type of the "librarian" service "get-books" endpoint HTTP response body.

func NewGetBooksResponseBody

func NewGetBooksResponseBody(res *librarianviews.GetbooksresponseView) *GetBooksResponseBody

NewGetBooksResponseBody builds the HTTP response body from the result of the "get-books" endpoint of the "librarian" 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 ResultbookResponseBody

type ResultbookResponseBody struct {
	// The unique id of the book.
	ID int `form:"id" json:"id" xml:"id"`
	// The title of the book.
	Title string `form:"title" json:"title" xml:"title"`
	// The author of the book.
	Author string `form:"author" json:"author" xml:"author"`
	// The cover image of the book.
	BookCover string `form:"book_cover" json:"book_cover" xml:"book_cover"`
	// The date at which the book was published.
	PublishedAt string `form:"published_at" json:"published_at" xml:"published_at"`
}

ResultbookResponseBody is used to define fields on response body types.

type ResultbookResponseBodyCollection

type ResultbookResponseBodyCollection []*ResultbookResponseBody

ResultbookResponseBodyCollection is used to define fields on response body types.

type Server

type Server struct {
	Mounts             []*MountPoint
	GetBook            http.Handler
	GetBooks           http.Handler
	CreateBook         http.Handler
	UpdateBook         http.Handler
	DeleteBook         http.Handler
	GenHTTPOpenapiJSON http.Handler
}

Server lists the librarian service endpoint HTTP handlers.

func New

func New(
	e *librarian.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,
	fileSystemGenHTTPOpenapiJSON http.FileSystem,
) *Server

New instantiates HTTP handlers for all the librarian 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 librarian 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 UpdateBookRequestBody

type UpdateBookRequestBody struct {
	// The unique id of the book.
	ID *int `form:"id,omitempty" json:"id,omitempty" xml:"id,omitempty"`
	// The title of the book.
	Title *string `form:"title,omitempty" json:"title,omitempty" xml:"title,omitempty"`
	// The author of the book.
	Author *string `form:"author,omitempty" json:"author,omitempty" xml:"author,omitempty"`
	// The URL to the cover image.
	BookCover *string `form:"book_cover,omitempty" json:"book_cover,omitempty" xml:"book_cover,omitempty"`
	// The date at which the book was published.
	PublishedAt *string `form:"published_at,omitempty" json:"published_at,omitempty" xml:"published_at,omitempty"`
}

UpdateBookRequestBody is the type of the "librarian" service "update-book" endpoint HTTP request body.

type UpdateBookResponseBody

type UpdateBookResponseBody struct {
	// The unique id of the book.
	ID int `form:"id" json:"id" xml:"id"`
	// The title of the book.
	Title string `form:"title" json:"title" xml:"title"`
	// The author of the book.
	Author string `form:"author" json:"author" xml:"author"`
	// The cover image of the book.
	BookCover string `form:"book_cover" json:"book_cover" xml:"book_cover"`
	// The date at which the book was published.
	PublishedAt string `form:"published_at" json:"published_at" xml:"published_at"`
}

UpdateBookResponseBody is the type of the "librarian" service "update-book" endpoint HTTP response body.

func NewUpdateBookResponseBody

func NewUpdateBookResponseBody(res *librarianviews.UpdatebookresponseView) *UpdateBookResponseBody

NewUpdateBookResponseBody builds the HTTP response body from the result of the "update-book" endpoint of the "librarian" service.

Jump to

Keyboard shortcuts

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