Documentation
¶
Overview ¶
Package rest 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 ¶
- func NewRouter(pool *pgxpool.Pool) (*gin.Engine, error)
- func RegisterHandlers(router gin.IRouter, si ServerInterface)
- func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)
- func Serve(ctx context.Context, pool *pgxpool.Pool, flags Flags) error
- type ErrorResponse
- type ErrorResponseError
- type Flags
- type GinServerOptions
- type LoginJSONBody
- type LoginJSONRequestBody
- type LogoutParams
- type MiddlewareFunc
- type ParseReportTextBody
- type ParseReportTextRequestBody
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) Login(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Logout(c *gin.Context)
- func (siw *ServerInterfaceWrapper) OpenapiJson(c *gin.Context)
- func (siw *ServerInterfaceWrapper) OpenapiYaml(c *gin.Context)
- func (siw *ServerInterfaceWrapper) ParseReport(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Ping(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Redoc(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Scalar(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(router gin.IRouter, si ServerInterface)
RegisterHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterHandlersWithOptions ¶
func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)
RegisterHandlersWithOptions creates http.Handler with additional options
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
// Description Human-readable description of the error
Description *string `json:"description,omitempty"`
// Error Error code, only somewhat human-readable
Error ErrorResponseError `json:"error"`
}
ErrorResponse A generic error response
type ErrorResponseError ¶
type ErrorResponseError string
ErrorResponseError Error code, only somewhat human-readable
const ( ErrorResponseErrorInternalServerError ErrorResponseError = "InternalServerError" ErrorResponseErrorInvalidBody ErrorResponseError = "InvalidBody" ErrorResponseErrorInvalidCredentials ErrorResponseError = "InvalidCredentials" ErrorResponseErrorMethodNotAllowed ErrorResponseError = "MethodNotAllowed" ErrorResponseErrorNotFound ErrorResponseError = "NotFound" ErrorResponseErrorReportInvalid ErrorResponseError = "ReportInvalid" )
Defines values for ErrorResponseError.
type Flags ¶
type Flags struct {
Address string `help:"The address to bind the REST API server to." default:":8080"`
}
type GinServerOptions ¶
type GinServerOptions struct {
BaseURL string
Middlewares []MiddlewareFunc
ErrorHandler func(*gin.Context, error, int)
}
GinServerOptions provides options for the Gin server.
type LoginJSONBody ¶
type LoginJSONBody struct {
// Password The password of the account.
Password string `json:"password"`
// Username The username of the account.
Username string `json:"username"`
}
LoginJSONBody defines parameters for Login.
type LoginJSONRequestBody ¶
type LoginJSONRequestBody LoginJSONBody
LoginJSONRequestBody defines body for Login for application/json ContentType.
type LogoutParams ¶
type LogoutParams struct {
// Session The session token to invalidate.
Session string `form:"session" json:"session"`
}
LogoutParams defines parameters for Logout.
type MiddlewareFunc ¶
type ParseReportTextBody ¶
type ParseReportTextBody = string
ParseReportTextBody defines parameters for ParseReport.
type ParseReportTextRequestBody ¶
type ParseReportTextRequestBody = ParseReportTextBody
ParseReportTextRequestBody defines body for ParseReport for text/plain ContentType.
type ServerInterface ¶
type ServerInterface interface {
// OpenAPI specification (JSON)
// (GET /api/openapi.json)
OpenapiJson(c *gin.Context)
// OpenAPI specification (YAML)
// (GET /api/openapi.yaml)
OpenapiYaml(c *gin.Context)
// Redoc documentation
// (GET /api/redoc)
Redoc(c *gin.Context)
// Scalar documentation
// (GET /api/scalar)
Scalar(c *gin.Context)
// Parse a code coverage report
// (POST /api/v0/parse-report)
ParseReport(c *gin.Context)
// Login to an account
// (POST /api/v1/login)
Login(c *gin.Context)
// Log out of an account
// (GET /api/v1/logout)
Logout(c *gin.Context, params LogoutParams)
// Ping the server
// (GET /api/v1/ping)
Ping(c *gin.Context)
}
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
ErrorHandler func(*gin.Context, error, int)
}
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) Login ¶
func (siw *ServerInterfaceWrapper) Login(c *gin.Context)
Login operation middleware
func (*ServerInterfaceWrapper) Logout ¶
func (siw *ServerInterfaceWrapper) Logout(c *gin.Context)
Logout operation middleware
func (*ServerInterfaceWrapper) OpenapiJson ¶
func (siw *ServerInterfaceWrapper) OpenapiJson(c *gin.Context)
OpenapiJson operation middleware
func (*ServerInterfaceWrapper) OpenapiYaml ¶
func (siw *ServerInterfaceWrapper) OpenapiYaml(c *gin.Context)
OpenapiYaml operation middleware
func (*ServerInterfaceWrapper) ParseReport ¶
func (siw *ServerInterfaceWrapper) ParseReport(c *gin.Context)
ParseReport operation middleware
func (*ServerInterfaceWrapper) Ping ¶
func (siw *ServerInterfaceWrapper) Ping(c *gin.Context)
Ping operation middleware
func (*ServerInterfaceWrapper) Redoc ¶
func (siw *ServerInterfaceWrapper) Redoc(c *gin.Context)
Redoc operation middleware
func (*ServerInterfaceWrapper) Scalar ¶
func (siw *ServerInterfaceWrapper) Scalar(c *gin.Context)
Scalar operation middleware