api

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 23 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.8.3 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
}

type Error

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

Error defines model for Error.

type GetGroupParams

type GetGroupParams struct {
	Token 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 `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"`
	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 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 SaveGroupJSONRequestBody

type SaveGroupJSONRequestBody SaveGroupRequest

SaveGroupJSONRequestBody defines body for SaveGroup for application/json ContentType.

type SaveGroupParams

type SaveGroupParams struct {
	Token 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
	// (GET /group)
	GetGroup(w http.ResponseWriter, r *http.Request, params GetGroupParams)
	// Save group
	// (POST /group)
	SaveGroup(w http.ResponseWriter, r *http.Request, params SaveGroupParams)
	// Healthcheck
	// (GET /healthcheck)
	Healthcheck(w http.ResponseWriter, r *http.Request)
	// Get token data
	// (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
}

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.

Jump to

Keyboard shortcuts

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