api

package
v0.0.0-...-96ae7f5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

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

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 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, m ServeMux) http.Handler

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

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

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

HandlerWithOptions creates http.Handler with additional options

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 CreateKeyValue201Response

type CreateKeyValue201Response struct {
}

func (CreateKeyValue201Response) VisitCreateKeyValueResponse

func (response CreateKeyValue201Response) VisitCreateKeyValueResponse(w http.ResponseWriter) error

type CreateKeyValue400Response

type CreateKeyValue400Response struct {
}

func (CreateKeyValue400Response) VisitCreateKeyValueResponse

func (response CreateKeyValue400Response) VisitCreateKeyValueResponse(w http.ResponseWriter) error

type CreateKeyValue409Response

type CreateKeyValue409Response struct {
}

func (CreateKeyValue409Response) VisitCreateKeyValueResponse

func (response CreateKeyValue409Response) VisitCreateKeyValueResponse(w http.ResponseWriter) error

type CreateKeyValueJSONBody

type CreateKeyValueJSONBody struct {
	// Value The new value to be associated with the key
	Value *string `json:"value,omitempty"`
}

CreateKeyValueJSONBody defines parameters for CreateKeyValue.

type CreateKeyValueJSONRequestBody

type CreateKeyValueJSONRequestBody CreateKeyValueJSONBody

CreateKeyValueJSONRequestBody defines body for CreateKeyValue for application/json ContentType.

type CreateKeyValueRequestObject

type CreateKeyValueRequestObject struct {
	Key  string `json:"key"`
	Body *CreateKeyValueJSONRequestBody
}

type CreateKeyValueResponseObject

type CreateKeyValueResponseObject interface {
	VisitCreateKeyValueResponse(w http.ResponseWriter) error
}

type DeleteKeyValue204Response

type DeleteKeyValue204Response struct {
}

func (DeleteKeyValue204Response) VisitDeleteKeyValueResponse

func (response DeleteKeyValue204Response) VisitDeleteKeyValueResponse(w http.ResponseWriter) error

type DeleteKeyValue404Response

type DeleteKeyValue404Response struct {
}

func (DeleteKeyValue404Response) VisitDeleteKeyValueResponse

func (response DeleteKeyValue404Response) VisitDeleteKeyValueResponse(w http.ResponseWriter) error

type DeleteKeyValueRequestObject

type DeleteKeyValueRequestObject struct {
	Key string `json:"key"`
}

type DeleteKeyValueResponseObject

type DeleteKeyValueResponseObject interface {
	VisitDeleteKeyValueResponse(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 ReadValue200JSONResponse

type ReadValue200JSONResponse string

func (ReadValue200JSONResponse) VisitReadValueResponse

func (response ReadValue200JSONResponse) VisitReadValueResponse(w http.ResponseWriter) error

type ReadValue404Response

type ReadValue404Response struct {
}

func (ReadValue404Response) VisitReadValueResponse

func (response ReadValue404Response) VisitReadValueResponse(w http.ResponseWriter) error

type ReadValueRequestObject

type ReadValueRequestObject struct {
	Key string `json:"key"`
}

type ReadValueResponseObject

type ReadValueResponseObject interface {
	VisitReadValueResponse(w http.ResponseWriter) error
}

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 ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

ServeMux is an abstraction of http.ServeMux.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(service Service, logger *slog.Logger) (*Server, error)

New creates a new API Server

func (Server) CreateKeyValue

func (Server) DeleteKeyValue

func (Server) ReadValue

func (Server) Run

func (s Server) Run(ctx context.Context) error

Run starts the API Server

func (Server) UpdateValue

type ServerInterface

type ServerInterface interface {
	// Delete key-value pair
	// (DELETE /{key})
	DeleteKeyValue(w http.ResponseWriter, r *http.Request, key string)
	// Read value
	// (GET /{key})
	ReadValue(w http.ResponseWriter, r *http.Request, key string)
	// Create key-value pair
	// (POST /{key})
	CreateKeyValue(w http.ResponseWriter, r *http.Request, key string)
	// Update value
	// (PUT /{key})
	UpdateValue(w http.ResponseWriter, r *http.Request, key string)
}

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

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

CreateKeyValue operation middleware

func (*ServerInterfaceWrapper) DeleteKeyValue

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

DeleteKeyValue operation middleware

func (*ServerInterfaceWrapper) ReadValue

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

ReadValue operation middleware

func (*ServerInterfaceWrapper) UpdateValue

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

UpdateValue operation middleware

type Service

type Service interface {
	DeleteKeyValue(ctx context.Context, key string) error
	ReadValue(ctx context.Context, key string) (string, error)
	CreateKeyValue(ctx context.Context, key, value string) error
	UpdateValue(ctx context.Context, key, value string) error
}

interface for the service used by the API Server

type StdHTTPServerOptions

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

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 {
	// Delete key-value pair
	// (DELETE /{key})
	DeleteKeyValue(ctx context.Context, request DeleteKeyValueRequestObject) (DeleteKeyValueResponseObject, error)
	// Read value
	// (GET /{key})
	ReadValue(ctx context.Context, request ReadValueRequestObject) (ReadValueResponseObject, error)
	// Create key-value pair
	// (POST /{key})
	CreateKeyValue(ctx context.Context, request CreateKeyValueRequestObject) (CreateKeyValueResponseObject, error)
	// Update value
	// (PUT /{key})
	UpdateValue(ctx context.Context, request UpdateValueRequestObject) (UpdateValueResponseObject, error)
}

StrictServerInterface represents all server handlers.

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 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 UpdateValue204Response

type UpdateValue204Response struct {
}

func (UpdateValue204Response) VisitUpdateValueResponse

func (response UpdateValue204Response) VisitUpdateValueResponse(w http.ResponseWriter) error

type UpdateValue400Response

type UpdateValue400Response struct {
}

func (UpdateValue400Response) VisitUpdateValueResponse

func (response UpdateValue400Response) VisitUpdateValueResponse(w http.ResponseWriter) error

type UpdateValue404Response

type UpdateValue404Response struct {
}

func (UpdateValue404Response) VisitUpdateValueResponse

func (response UpdateValue404Response) VisitUpdateValueResponse(w http.ResponseWriter) error

type UpdateValueJSONBody

type UpdateValueJSONBody struct {
	// Value The new value to be associated with the key
	Value *string `json:"value,omitempty"`
}

UpdateValueJSONBody defines parameters for UpdateValue.

type UpdateValueJSONRequestBody

type UpdateValueJSONRequestBody UpdateValueJSONBody

UpdateValueJSONRequestBody defines body for UpdateValue for application/json ContentType.

type UpdateValueRequestObject

type UpdateValueRequestObject struct {
	Key  string `json:"key"`
	Body *UpdateValueJSONRequestBody
}

type UpdateValueResponseObject

type UpdateValueResponseObject interface {
	VisitUpdateValueResponse(w http.ResponseWriter) error
}

Jump to

Keyboard shortcuts

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