api

package
v0.0.0-...-283825e Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package api 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

This section is empty.

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 NewWeatherService

func NewWeatherService(config WeatherServiceConfig) *weatherService

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 ChiServerOptions

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

type Coordinate

type Coordinate = float32

Coordinate defines model for Coordinate.

type ErrorMessage

type ErrorMessage struct {
	Error string `json:"error"`
}

ErrorMessage defines model for ErrorMessage.

type GetWeather200JSONResponse

type GetWeather200JSONResponse struct {
	TemperatureSummary Temperature `json:"temperature_summary"`
	WeatherCondition   string      `json:"weather_condition"`
}

func (GetWeather200JSONResponse) VisitGetWeatherResponse

func (response GetWeather200JSONResponse) VisitGetWeatherResponse(w http.ResponseWriter) error

type GetWeather400JSONResponse

type GetWeather400JSONResponse ErrorMessage

func (GetWeather400JSONResponse) VisitGetWeatherResponse

func (response GetWeather400JSONResponse) VisitGetWeatherResponse(w http.ResponseWriter) error

type GetWeatherParams

type GetWeatherParams struct {
	Lat *Coordinate `form:"lat,omitempty" json:"lat,omitempty"`
	Lon *Coordinate `form:"lon,omitempty" json:"lon,omitempty"`
}

GetWeatherParams defines parameters for GetWeather.

type GetWeatherRequestObject

type GetWeatherRequestObject struct {
	Params GetWeatherParams
}

type GetWeatherResponseObject

type GetWeatherResponseObject interface {
	VisitGetWeatherResponse(w http.ResponseWriter) 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 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 ServerInterface

type ServerInterface interface {

	// (GET /weather)
	GetWeather(w http.ResponseWriter, r *http.Request, params GetWeatherParams)
}

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) GetWeather

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

GetWeather 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 {

	// (GET /weather)
	GetWeather(ctx context.Context, request GetWeatherRequestObject) (GetWeatherResponseObject, error)
}

StrictServerInterface represents all server handlers.

type Temperature

type Temperature string

Temperature defines model for Temperature.

const (
	COLD     Temperature = "COLD"
	HOT      Temperature = "HOT"
	MODERATE Temperature = "MODERATE"
)

Defines values for Temperature.

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) GetWeather

func (_ Unimplemented) GetWeather(w http.ResponseWriter, r *http.Request, params GetWeatherParams)

(GET /weather)

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

type WeatherServiceConfig

type WeatherServiceConfig struct {
	WeatherUtil weather.WeatherUtil
	// Anything below specified ColdTemp will be summarized as "COLD"
	ColdTemp int
	// Anything above HotTemp will be summarized as "HOT" (this must be greater than ColdTemp )
	HotTemp int
}

Jump to

Keyboard shortcuts

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