handlers

package
v0.0.0-...-a8dead8 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

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

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT.

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

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT.

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

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT.

Index

Constants

View Source
const (
	BearerAuthScopes = "bearerAuth.Scopes"
)

Variables

This section is empty.

Functions

func Get

func Get[T any](v *T) T

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 RegisterOApiHandlers

func RegisterOApiHandlers(r chi.Router, validateUsers bool, database *database.Sqlite)

Types

type ChiServerOptions

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

type Comment

type Comment struct {
	// Author Author of the comment.
	Author *string `json:"author,omitempty"`

	// Date Date when comment was created.
	Date time.Time `json:"date"`

	// Edits Number of edits done to the comment.
	Edits int `json:"edits"`

	// Id The comment id.
	Id string `json:"id"`

	// Position Position of the comment in reply list.
	Position int `json:"position"`

	// Replies Number of replies to the comment.
	Replies int `json:"replies"`

	// Text Text of the comment.
	Text string `json:"text"`
}

Comment defines model for Comment.

type CommentHistory

type CommentHistory struct {
	// Date Date when comment was created.
	Date time.Time `json:"date"`

	// Text Text of the comment.
	Text string `json:"text"`
}

CommentHistory defines model for CommentHistory.

type CommentHistoryPage

type CommentHistoryPage struct {
	Comment       CommentSimple    `json:"comment"`
	Content       []CommentHistory `json:"content"`
	First         bool             `json:"first"`
	Last          bool             `json:"last"`
	Size          int              `json:"size"`
	TotalElements int64            `json:"totalElements"`
	TotalPages    int              `json:"totalPages"`
}

CommentHistoryPage defines model for CommentHistoryPage.

type CommentSimple

type CommentSimple struct {
	// Author Author of the comment.
	Author *string `json:"author,omitempty"`

	// Date Date when comment was created.
	Date time.Time `json:"date"`

	// Id The comment id.
	Id string `json:"id"`

	// Text Text of the comment.
	Text string `json:"text"`
}

CommentSimple defines model for CommentSimple.

type CommentsPage

type CommentsPage struct {
	Content       []Comment `json:"content"`
	First         bool      `json:"first"`
	Last          bool      `json:"last"`
	Size          int       `json:"size"`
	Subject       Subject   `json:"subject"`
	TotalElements int64     `json:"totalElements"`
	TotalPages    int       `json:"totalPages"`
}

CommentsPage defines model for CommentsPage.

type CreateComment

type CreateComment struct {
	// SubjectName Name of the subject
	SubjectName *string `json:"subjectName,omitempty"`

	// Text Text of the comment
	Text string `json:"text"`
}

CreateComment defines model for CreateComment.

type CreateComment200JSONResponse

type CreateComment200JSONResponse Comment

func (CreateComment200JSONResponse) VisitCreateCommentResponse

func (response CreateComment200JSONResponse) VisitCreateCommentResponse(w http.ResponseWriter) error

type CreateComment400JSONResponse

type CreateComment400JSONResponse Error

func (CreateComment400JSONResponse) VisitCreateCommentResponse

func (response CreateComment400JSONResponse) VisitCreateCommentResponse(w http.ResponseWriter) error

type CreateComment500JSONResponse

type CreateComment500JSONResponse Error

func (CreateComment500JSONResponse) VisitCreateCommentResponse

func (response CreateComment500JSONResponse) VisitCreateCommentResponse(w http.ResponseWriter) error

type CreateCommentJSONRequestBody

type CreateCommentJSONRequestBody = CreateComment

CreateCommentJSONRequestBody defines body for CreateComment for application/json ContentType.

type CreateCommentRequestObject

type CreateCommentRequestObject struct {
	Subject string `json:"subject"`
	Body    *CreateCommentJSONRequestBody
}

type CreateCommentResponseObject

type CreateCommentResponseObject interface {
	VisitCreateCommentResponse(w http.ResponseWriter) error
}

type EditComment

type EditComment struct {
	// Text Text of the comment
	Text string `json:"text"`
}

EditComment defines model for EditComment.

type EditComment200JSONResponse

type EditComment200JSONResponse CommentSimple

func (EditComment200JSONResponse) VisitEditCommentResponse

func (response EditComment200JSONResponse) VisitEditCommentResponse(w http.ResponseWriter) error

type EditComment400JSONResponse

type EditComment400JSONResponse Error

func (EditComment400JSONResponse) VisitEditCommentResponse

func (response EditComment400JSONResponse) VisitEditCommentResponse(w http.ResponseWriter) error

type EditComment404JSONResponse

type EditComment404JSONResponse Error

func (EditComment404JSONResponse) VisitEditCommentResponse

func (response EditComment404JSONResponse) VisitEditCommentResponse(w http.ResponseWriter) error

type EditComment500JSONResponse

type EditComment500JSONResponse Error

func (EditComment500JSONResponse) VisitEditCommentResponse

func (response EditComment500JSONResponse) VisitEditCommentResponse(w http.ResponseWriter) error

type EditCommentJSONRequestBody

type EditCommentJSONRequestBody = EditComment

EditCommentJSONRequestBody defines body for EditComment for application/json ContentType.

type EditCommentRequestObject

type EditCommentRequestObject struct {
	Comment string `json:"comment"`
	Body    *EditCommentJSONRequestBody
}

type EditCommentResponseObject

type EditCommentResponseObject interface {
	VisitEditCommentResponse(w http.ResponseWriter) error
}

type Error

type Error struct {
	// Code Error code.
	Code string `json:"code"`

	// Message A detailed message of the error.
	Message string `json:"message"`

	// Severity An exception class indicating the occurred error.
	Severity string `json:"severity"`
}

Error defines model for Error.

type GetCommentHistory200JSONResponse

type GetCommentHistory200JSONResponse CommentHistoryPage

func (GetCommentHistory200JSONResponse) VisitGetCommentHistoryResponse

func (response GetCommentHistory200JSONResponse) VisitGetCommentHistoryResponse(w http.ResponseWriter) error

type GetCommentHistory400JSONResponse

type GetCommentHistory400JSONResponse Error

func (GetCommentHistory400JSONResponse) VisitGetCommentHistoryResponse

func (response GetCommentHistory400JSONResponse) VisitGetCommentHistoryResponse(w http.ResponseWriter) error

type GetCommentHistory404JSONResponse

type GetCommentHistory404JSONResponse Error

func (GetCommentHistory404JSONResponse) VisitGetCommentHistoryResponse

func (response GetCommentHistory404JSONResponse) VisitGetCommentHistoryResponse(w http.ResponseWriter) error

type GetCommentHistoryParams

type GetCommentHistoryParams struct {
	// Size Return maximum of <limit> number of definitions. Default 20.
	Size *int `form:"size,omitempty" json:"size,omitempty"`

	// Page Page of the comments to retrieve (starts at 0).
	Page *int `form:"page,omitempty" json:"page,omitempty"`
}

GetCommentHistoryParams defines parameters for GetCommentHistory.

type GetCommentHistoryRequestObject

type GetCommentHistoryRequestObject struct {
	Comment string `json:"comment"`
	Params  GetCommentHistoryParams
}

type GetCommentHistoryResponseObject

type GetCommentHistoryResponseObject interface {
	VisitGetCommentHistoryResponse(w http.ResponseWriter) error
}

type GetCommentsPage200JSONResponse

type GetCommentsPage200JSONResponse CommentsPage

func (GetCommentsPage200JSONResponse) VisitGetCommentsPageResponse

func (response GetCommentsPage200JSONResponse) VisitGetCommentsPageResponse(w http.ResponseWriter) error

type GetCommentsPage400JSONResponse

type GetCommentsPage400JSONResponse Error

func (GetCommentsPage400JSONResponse) VisitGetCommentsPageResponse

func (response GetCommentsPage400JSONResponse) VisitGetCommentsPageResponse(w http.ResponseWriter) error

type GetCommentsPage404JSONResponse

type GetCommentsPage404JSONResponse Error

func (GetCommentsPage404JSONResponse) VisitGetCommentsPageResponse

func (response GetCommentsPage404JSONResponse) VisitGetCommentsPageResponse(w http.ResponseWriter) error

type GetCommentsPageParams

type GetCommentsPageParams struct {
	// Size Return maximum of <limit> number of definitions. Default 20.
	Size *int `form:"size,omitempty" json:"size,omitempty"`

	// Page Page of the comments to retrieve (starts at 0).
	Page *int `form:"page,omitempty" json:"page,omitempty"`
}

GetCommentsPageParams defines parameters for GetCommentsPage.

type GetCommentsPageRequestObject

type GetCommentsPageRequestObject struct {
	Subject string `json:"subject"`
	Params  GetCommentsPageParams
}

type GetCommentsPageResponseObject

type GetCommentsPageResponseObject interface {
	VisitGetCommentsPageResponse(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 OApiHandlers

type OApiHandlers struct {
	ValidateUsers bool
	DB            *database.Sqlite
}

func (OApiHandlers) CreateComment

func (OApiHandlers) EditComment

func (OApiHandlers) GetCommentsPage

type Page

type Page struct {
	First         bool  `json:"first"`
	Last          bool  `json:"last"`
	Size          int   `json:"size"`
	TotalElements int64 `json:"totalElements"`
	TotalPages    int   `json:"totalPages"`
}

Page defines model for Page.

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 {
	// Edit comment
	// (PATCH /comment/{comment})
	EditComment(w http.ResponseWriter, r *http.Request, comment string)
	// Get comment history
	// (GET /comment/{comment}/history)
	GetCommentHistory(w http.ResponseWriter, r *http.Request, comment string, params GetCommentHistoryParams)
	// Get a page of comments
	// (GET /subject/{subject}/comment)
	GetCommentsPage(w http.ResponseWriter, r *http.Request, subject string, params GetCommentsPageParams)
	// Create a comment to subject (if subject is another comment you can create nested comments).
	// (POST /subject/{subject}/comment)
	CreateComment(w http.ResponseWriter, r *http.Request, subject string)
}

ServerInterface represents all server handlers.

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

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

CreateComment operation middleware

func (*ServerInterfaceWrapper) EditComment

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

EditComment operation middleware

func (*ServerInterfaceWrapper) GetCommentHistory

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

GetCommentHistory operation middleware

func (*ServerInterfaceWrapper) GetCommentsPage

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

GetCommentsPage 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 {
	// Edit comment
	// (PATCH /comment/{comment})
	EditComment(ctx context.Context, request EditCommentRequestObject) (EditCommentResponseObject, error)
	// Get comment history
	// (GET /comment/{comment}/history)
	GetCommentHistory(ctx context.Context, request GetCommentHistoryRequestObject) (GetCommentHistoryResponseObject, error)
	// Get a page of comments
	// (GET /subject/{subject}/comment)
	GetCommentsPage(ctx context.Context, request GetCommentsPageRequestObject) (GetCommentsPageResponseObject, error)
	// Create a comment to subject (if subject is another comment you can create nested comments).
	// (POST /subject/{subject}/comment)
	CreateComment(ctx context.Context, request CreateCommentRequestObject) (CreateCommentResponseObject, error)
}

StrictServerInterface represents all server handlers.

type Subject

type Subject struct {
	// Id Id of the subject that the comment belongs to.
	Id string `json:"id"`

	// Name Name of the subject that the comment belongs to.
	Name *string `json:"name,omitempty"`
}

Subject defines model for Subject.

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

func (_ Unimplemented) CreateComment(w http.ResponseWriter, r *http.Request, subject string)

Create a comment to subject (if subject is another comment you can create nested comments). (POST /subject/{subject}/comment)

func (Unimplemented) EditComment

func (_ Unimplemented) EditComment(w http.ResponseWriter, r *http.Request, comment string)

Edit comment (PATCH /comment/{comment})

func (Unimplemented) GetCommentHistory

func (_ Unimplemented) GetCommentHistory(w http.ResponseWriter, r *http.Request, comment string, params GetCommentHistoryParams)

Get comment history (GET /comment/{comment}/history)

func (Unimplemented) GetCommentsPage

func (_ Unimplemented) GetCommentsPage(w http.ResponseWriter, r *http.Request, subject string, params GetCommentsPageParams)

Get a page of comments (GET /subject/{subject}/comment)

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