server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

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

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.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 PathToRawSpec

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

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

func Start

func Start(port int, frontendFS fs.FS, configPath string) error

Types

type ChiServerOptions

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

type GetConfig200JSONResponse

type GetConfig200JSONResponse externalRef0.Config

func (GetConfig200JSONResponse) VisitGetConfigResponse

func (response GetConfig200JSONResponse) VisitGetConfigResponse(w http.ResponseWriter) error

type GetConfig500Response

type GetConfig500Response struct {
}

func (GetConfig500Response) VisitGetConfigResponse

func (response GetConfig500Response) VisitGetConfigResponse(w http.ResponseWriter) error

type GetConfigRequestObject

type GetConfigRequestObject struct {
}

type GetConfigResponseObject

type GetConfigResponseObject interface {
	VisitGetConfigResponse(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 PutConfig200Response

type PutConfig200Response struct {
}

func (PutConfig200Response) VisitPutConfigResponse

func (response PutConfig200Response) VisitPutConfigResponse(w http.ResponseWriter) error

type PutConfig400Response

type PutConfig400Response struct {
}

func (PutConfig400Response) VisitPutConfigResponse

func (response PutConfig400Response) VisitPutConfigResponse(w http.ResponseWriter) error

type PutConfig500Response

type PutConfig500Response struct {
}

func (PutConfig500Response) VisitPutConfigResponse

func (response PutConfig500Response) VisitPutConfigResponse(w http.ResponseWriter) error

type PutConfigJSONRequestBody

type PutConfigJSONRequestBody = externalRef0.Config

PutConfigJSONRequestBody defines body for PutConfig for application/json ContentType.

type PutConfigRequestObject

type PutConfigRequestObject struct {
	Body *PutConfigJSONRequestBody
}

type PutConfigResponseObject

type PutConfigResponseObject interface {
	VisitPutConfigResponse(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 Server

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

func (Server) PutConfig

type ServerInterface

type ServerInterface interface {
	// Get current configuration
	// (GET /config)
	GetConfig(w http.ResponseWriter, r *http.Request)
	// Update configuration
	// (PUT /config)
	PutConfig(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

func NewServer

func NewServer(configPath string) ServerInterface

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

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

GetConfig operation middleware

func (*ServerInterfaceWrapper) PutConfig

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

PutConfig 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 current configuration
	// (GET /config)
	GetConfig(ctx context.Context, request GetConfigRequestObject) (GetConfigResponseObject, error)
	// Update configuration
	// (PUT /config)
	PutConfig(ctx context.Context, request PutConfigRequestObject) (PutConfigResponseObject, 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 Unimplemented

type Unimplemented struct{}

func (Unimplemented) GetConfig

func (_ Unimplemented) GetConfig(w http.ResponseWriter, r *http.Request)

Get current configuration (GET /config)

func (Unimplemented) PutConfig

func (_ Unimplemented) PutConfig(w http.ResponseWriter, r *http.Request)

Update configuration (PUT /config)

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