server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package server provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Index

Constants

View Source
const (
	Api_keyScopes = "api_key.Scopes"
)

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func NewRouter

func NewRouter() (http.Handler, error)

NewRouter creates a new handler for server routes

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type Author

type Author = string

Author defines model for author.

type BookMetadata

type BookMetadata struct {
	Asin   *string `json:"asin,omitempty"`
	Author *string `json:"author,omitempty"`

	// Cover URL to the cover image
	Cover       *string `json:"cover,omitempty"`
	Description *string `json:"description,omitempty"`

	// Duration Duration in seconds
	Duration      *int              `json:"duration,omitempty"`
	Genres        *[]string         `json:"genres,omitempty"`
	Isbn          *string           `json:"isbn,omitempty"`
	Language      *string           `json:"language,omitempty"`
	Narrator      *string           `json:"narrator,omitempty"`
	PublishedYear *string           `json:"publishedYear,omitempty"`
	Publisher     *string           `json:"publisher,omitempty"`
	Series        *[]SeriesMetadata `json:"series,omitempty"`
	Subtitle      *string           `json:"subtitle,omitempty"`
	Tags          *[]string         `json:"tags,omitempty"`
	Title         string            `json:"title"`
}

BookMetadata defines model for BookMetadata.

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type N200

type N200 struct {
	Matches *[]BookMetadata `json:"matches,omitempty"`
}

N200 defines model for 200.

type N200JSONResponse

type N200JSONResponse struct {
	Matches *[]BookMetadata `json:"matches,omitempty"`
}

type N400

type N400 struct {
	Error *string `json:"error,omitempty"`
}

N400 defines model for 400.

type N400JSONResponse

type N400JSONResponse struct {
	Error *string `json:"error,omitempty"`
}

type N401

type N401 struct {
	Error *string `json:"error,omitempty"`
}

N401 defines model for 401.

type N401JSONResponse

type N401JSONResponse struct {
	Error *string `json:"error,omitempty"`
}

type N500

type N500 struct {
	Error *string `json:"error,omitempty"`
}

N500 defines model for 500.

type N500JSONResponse

type N500JSONResponse struct {
	Error *string `json:"error,omitempty"`
}

type Query

type Query = string

Query defines model for query.

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type SearchGoodreads200JSONResponse

type SearchGoodreads200JSONResponse struct{ N200JSONResponse }

func (SearchGoodreads200JSONResponse) VisitSearchGoodreadsResponse

func (response SearchGoodreads200JSONResponse) VisitSearchGoodreadsResponse(w http.ResponseWriter) error

type SearchGoodreads400JSONResponse

type SearchGoodreads400JSONResponse struct{ N400JSONResponse }

func (SearchGoodreads400JSONResponse) VisitSearchGoodreadsResponse

func (response SearchGoodreads400JSONResponse) VisitSearchGoodreadsResponse(w http.ResponseWriter) error

type SearchGoodreads401JSONResponse

type SearchGoodreads401JSONResponse struct{ N401JSONResponse }

func (SearchGoodreads401JSONResponse) VisitSearchGoodreadsResponse

func (response SearchGoodreads401JSONResponse) VisitSearchGoodreadsResponse(w http.ResponseWriter) error

type SearchGoodreads500JSONResponse

type SearchGoodreads500JSONResponse struct{ N500JSONResponse }

func (SearchGoodreads500JSONResponse) VisitSearchGoodreadsResponse

func (response SearchGoodreads500JSONResponse) VisitSearchGoodreadsResponse(w http.ResponseWriter) error

type SearchGoodreadsParams

type SearchGoodreadsParams struct {
	Query  Query   `form:"query" json:"query"`
	Author *Author `form:"author,omitempty" json:"author,omitempty"`
}

SearchGoodreadsParams defines parameters for SearchGoodreads.

type SearchGoodreadsRequestObject

type SearchGoodreadsRequestObject struct {
	Params SearchGoodreadsParams
}

type SearchGoodreadsResponseObject

type SearchGoodreadsResponseObject interface {
	VisitSearchGoodreadsResponse(w http.ResponseWriter) error
}

type SearchKindle200JSONResponse

type SearchKindle200JSONResponse struct{ N200JSONResponse }

func (SearchKindle200JSONResponse) VisitSearchKindleResponse

func (response SearchKindle200JSONResponse) VisitSearchKindleResponse(w http.ResponseWriter) error

type SearchKindle400JSONResponse

type SearchKindle400JSONResponse struct{ N400JSONResponse }

func (SearchKindle400JSONResponse) VisitSearchKindleResponse

func (response SearchKindle400JSONResponse) VisitSearchKindleResponse(w http.ResponseWriter) error

type SearchKindle401JSONResponse

type SearchKindle401JSONResponse struct{ N401JSONResponse }

func (SearchKindle401JSONResponse) VisitSearchKindleResponse

func (response SearchKindle401JSONResponse) VisitSearchKindleResponse(w http.ResponseWriter) error

type SearchKindle500JSONResponse

type SearchKindle500JSONResponse struct{ N500JSONResponse }

func (SearchKindle500JSONResponse) VisitSearchKindleResponse

func (response SearchKindle500JSONResponse) VisitSearchKindleResponse(w http.ResponseWriter) error

type SearchKindleParams

type SearchKindleParams struct {
	Query  Query   `form:"query" json:"query"`
	Author *Author `form:"author,omitempty" json:"author,omitempty"`
}

SearchKindleParams defines parameters for SearchKindle.

type SearchKindleParamsRegion

type SearchKindleParamsRegion string

SearchKindleParamsRegion defines parameters for SearchKindle.

Defines values for SearchKindleParamsRegion.

type SearchKindleRequestObject

type SearchKindleRequestObject struct {
	Region SearchKindleParamsRegion `json:"region,omitempty"`
	Params SearchKindleParams
}

type SearchKindleResponseObject

type SearchKindleResponseObject interface {
	VisitSearchKindleResponse(w http.ResponseWriter) error
}

type SeriesMetadata

type SeriesMetadata struct {
	Sequence *string `json:"sequence,omitempty"`
	Series   string  `json:"series"`
}

SeriesMetadata defines model for SeriesMetadata.

type ServerInterface

type ServerInterface interface {
	// Search for books using goodreads
	// (GET /goodreads/search)
	SearchGoodreads(w http.ResponseWriter, r *http.Request, params SearchGoodreadsParams)
	// Search for books using kindle
	// (GET /kindle/{region}/search)
	SearchKindle(w http.ResponseWriter, r *http.Request, region SearchKindleParamsRegion, params SearchKindleParams)
}

ServerInterface represents all server handlers.

func NewStrictHandler

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

func NewStrictHandlerWithOptions

func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) SearchGoodreads

func (siw *ServerInterfaceWrapper) SearchGoodreads(w http.ResponseWriter, r *http.Request)

SearchGoodreads operation middleware

func (*ServerInterfaceWrapper) SearchKindle

func (siw *ServerInterfaceWrapper) SearchKindle(w http.ResponseWriter, r *http.Request)

SearchKindle operation middleware

type StrictHTTPServerOptions

type StrictHTTPServerOptions struct {
	RequestErrorHandlerFunc  func(w http.ResponseWriter, r *http.Request, err error)
	ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictServerInterface

type StrictServerInterface interface {
	// Search for books using goodreads
	// (GET /goodreads/search)
	SearchGoodreads(ctx context.Context, request SearchGoodreadsRequestObject) (SearchGoodreadsResponseObject, error)
	// Search for books using kindle
	// (GET /kindle/{region}/search)
	SearchKindle(ctx context.Context, request SearchKindleRequestObject) (SearchKindleResponseObject, error)
}

StrictServerInterface represents all server handlers.

func NewServer

func NewServer() StrictServerInterface

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type Unimplemented

type Unimplemented struct{}

func (Unimplemented) SearchGoodreads

func (_ Unimplemented) SearchGoodreads(w http.ResponseWriter, r *http.Request, params SearchGoodreadsParams)

Search for books using goodreads (GET /goodreads/search)

func (Unimplemented) SearchKindle

Search for books using kindle (GET /kindle/{region}/search)

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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