api

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen version v1.11.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.

Types

type API

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

func NewAPI

func NewAPI(opts Options) (*API, error)

func (*API) GetGroup

func (hdl *API) GetGroup(w http.ResponseWriter, r *http.Request, params GetGroupParams)

func (*API) GetHTTPRouter

func (hdl *API) GetHTTPRouter() *chi.Mux

func (*API) GetTokenData

func (hdl *API) GetTokenData(w http.ResponseWriter, r *http.Request, params GetTokenDataParams)

func (*API) Healthcheck

func (hdl *API) Healthcheck(w http.ResponseWriter, r *http.Request)

func (*API) SaveGroup

func (hdl *API) SaveGroup(w http.ResponseWriter, r *http.Request, params SaveGroupParams)

type Answer

type Answer struct {
	Correct *bool  `json:"correct,omitempty"`
	Text    string `json:"text"`
}

Answer defines model for Answer.

type Answers

type Answers = []Answer

Answers defines model for Answers.

type ChiServerOptions

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

type Domain added in v1.5.0

type Domain = string

Domain defines model for Domain.

type Domains added in v1.5.0

type Domains = []Domain

Domains defines model for Domains.

type Error

type Error struct {
	Message string `json:"message"`
}

Error defines model for Error.

type GetGroupParams

type GetGroupParams struct {
	Token Token `form:"token" json:"token"`
}

GetGroupParams defines parameters for GetGroup.

type GetGroupResponse

type GetGroupResponse = Group

GetGroupResponse defines model for GetGroupResponse.

type GetTokenDataParams

type GetTokenDataParams struct {
	Token Token `form:"token" json:"token"`
}

GetTokenDataParams defines parameters for GetTokenData.

type GetTokenResponse

type GetTokenResponse = TokenData

GetTokenResponse defines model for GetTokenResponse.

type Group

type Group struct {
	BanQuestion   bool      `json:"ban_question"`
	BanTimeout    int32     `json:"ban_timeout"`
	BanUrl        bool      `json:"ban_url"`
	Greeting      string    `json:"greeting"`
	Id            int64     `json:"id"`
	IgnoreDomains *Domains  `json:"ignore_domains,omitempty"`
	Questions     Questions `json:"questions"`
}

Group defines model for Group.

type Healthcheck

type Healthcheck = map[string]interface{}

Healthcheck defines model for Healthcheck.

type HealthcheckResponse

type HealthcheckResponse = Healthcheck

HealthcheckResponse defines model for HealthcheckResponse.

type InternalErrorResponse

type InternalErrorResponse = Error

InternalErrorResponse defines model for InternalErrorResponse.

type InvalidParamFormatError added in v1.5.0

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error added in v1.5.0

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap added in v1.5.0

func (e *InvalidParamFormatError) Unwrap() error

type MiddlewareFunc

type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc

type NotFoundErrorResponse

type NotFoundErrorResponse = Error

NotFoundErrorResponse defines model for NotFoundErrorResponse.

type Options

type Options struct {
	Log     *zap.SugaredLogger
	Model   *model.Model
	Storage *storage.InstanceObj
}

type Question

type Question struct {
	Answers Answers `json:"answers"`
	Text    string  `json:"text"`
}

Question defines model for Question.

type Questions

type Questions = []Question

Questions defines model for Questions.

type RequiredHeaderError added in v1.5.0

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error added in v1.5.0

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap added in v1.5.0

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError added in v1.5.0

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error added in v1.5.0

func (e *RequiredParamError) Error() string

type SaveGroupJSONRequestBody

type SaveGroupJSONRequestBody = SaveGroupRequest

SaveGroupJSONRequestBody defines body for SaveGroup for application/json ContentType.

type SaveGroupParams

type SaveGroupParams struct {
	Token Token `form:"token" json:"token"`
}

SaveGroupParams defines parameters for SaveGroup.

type SaveGroupRequest

type SaveGroupRequest = Group

SaveGroupRequest defines model for SaveGroupRequest.

type SaveGroupResponse

type SaveGroupResponse = map[string]interface{}

SaveGroupResponse defines model for SaveGroupResponse.

type ServerInterface

type ServerInterface interface {

	// (GET /group)
	GetGroup(w http.ResponseWriter, r *http.Request, params GetGroupParams)

	// (POST /group)
	SaveGroup(w http.ResponseWriter, r *http.Request, params SaveGroupParams)

	// (GET /healthcheck)
	Healthcheck(w http.ResponseWriter, r *http.Request)

	// (GET /token)
	GetTokenData(w http.ResponseWriter, r *http.Request, params GetTokenDataParams)
}

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

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

GetGroup operation middleware

func (*ServerInterfaceWrapper) GetTokenData

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

GetTokenData operation middleware

func (*ServerInterfaceWrapper) Healthcheck

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

Healthcheck operation middleware

func (*ServerInterfaceWrapper) SaveGroup

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

SaveGroup operation middleware

type Token

type Token = string

Token defines model for Token.

type TokenData

type TokenData struct {
	Ttl string `json:"ttl"`
}

TokenData defines model for TokenData.

type TooManyValuesForParamError added in v1.5.0

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error added in v1.5.0

type UnescapedCookieParamError added in v1.5.0

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error added in v1.5.0

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap added in v1.5.0

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError added in v1.5.0

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error added in v1.5.0

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap added in v1.5.0

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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