ports

package
v0.0.0-...-b60b57f Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

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

Code generated by unknown module path version unknown version DO NOT EDIT.

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

Code generated by unknown module path version unknown version 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.

Types

type AddUserJSONBody

type AddUserJSONBody NewUser

AddUserJSONBody defines parameters for AddUser.

type AddUserJSONRequestBody

type AddUserJSONRequestBody AddUserJSONBody

AddUserJSONRequestBody defines body for AddUser for application/json ContentType.

type ChiServerOptions

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

type Error

type Error struct {
	// Error code
	Code int32 `json:"code"`

	// Error message
	Message string `json:"message"`
}

Error defines model for Error.

type Http

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

func NewHttp

func NewHttp(logger *zap.Logger, service Service) *Http

func (*Http) AddUser

func (h *Http) AddUser(w http.ResponseWriter, r *http.Request)

func (*Http) DeleteUser

func (h *Http) DeleteUser(w http.ResponseWriter, _ *http.Request, id types.UUID)

func (*Http) FindAllUsers

func (h *Http) FindAllUsers(w http.ResponseWriter, r *http.Request)

func (*Http) FindUserByID

func (h *Http) FindUserByID(w http.ResponseWriter, r *http.Request, id types.UUID)

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.HandlerFunc) http.HandlerFunc

type NewUser

type NewUser struct {
	// Name of the user
	Name string `json:"name"`

	// Type of the user
	Tag *string `json:"tag,omitempty"`
}

NewUser defines model for NewUser.

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 {
	// Returns all users
	// (GET /api/users)
	FindAllUsers(w http.ResponseWriter, r *http.Request)
	// Creates a new user
	// (POST /api/users)
	AddUser(w http.ResponseWriter, r *http.Request)
	// Deletes a user by ID
	// (DELETE /api/users/{id})
	DeleteUser(w http.ResponseWriter, r *http.Request, id openapi_types.UUID)
	// Returns a user by ID
	// (GET /api/users/{id})
	FindUserByID(w http.ResponseWriter, r *http.Request, id openapi_types.UUID)
}

ServerInterface represents all server handlers.

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

AddUser operation middleware

func (*ServerInterfaceWrapper) DeleteUser

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

DeleteUser operation middleware

func (*ServerInterfaceWrapper) FindAllUsers

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

FindAllUsers operation middleware

func (*ServerInterfaceWrapper) FindUserByID

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

FindUserByID operation middleware

type Service

type Service interface {
	Add(user User) error
	Delete(id string) error
	FindAll() ([]User, error)
	FindByID(id string) (User, error)
}

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 User

type User struct {
	// Embedded struct due to allOf(#/components/schemas/NewUser)
	NewUser `yaml:",inline"`
	// Embedded fields due to inline allOf schema
	// Unique id of the user
	Id openapi_types.UUID `json:"id"`
}

User defines model for User.

Jump to

Keyboard shortcuts

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