handlers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: LGPL-3.0 Imports: 12 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.4.1 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 PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type APIHandler

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

APIHandler handles the requests to vecchiochan.

func NewAPIHandler

func NewAPIHandler(userAgent string, verbose bool) *APIHandler

NewAPIHandler creates a new handler with a VecchioClient.

func (*APIHandler) NewThread

func (h *APIHandler) NewThread(ctx echo.Context) error

NewThread Create a new thread on a specific board

func (*APIHandler) PostReply

func (h *APIHandler) PostReply(ctx echo.Context) error

PostReply Post a reply to an existing thread

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type ErrorResponse

type ErrorResponse struct {
	// Error Error describing the failure in submitting the thread/reply
	Error string `json:"error"`
}

ErrorResponse defines model for ErrorResponse.

type NewThreadJSONRequestBody

type NewThreadJSONRequestBody = Thread

NewThreadJSONRequestBody defines body for NewThread for application/json ContentType.

type PostReplyJSONRequestBody

type PostReplyJSONRequestBody = Reply

PostReplyJSONRequestBody defines body for PostReply for application/json ContentType.

type Reply

type Reply struct {
	// Board Board where the reply is to be posted (e.g., 'b').
	Board string `json:"board"`

	// Body The message of the reply.
	Body *string `json:"body,omitempty"`

	// Email Email of the poster.
	Email *string `json:"email,omitempty"`

	// Embed URL for an embedded media link (YouTube, Spotify...).
	Embed *string `json:"embed,omitempty"`

	// Files Paths of the files to attach to the reply.
	Files *[]string `json:"files,omitempty"`

	// Name Name of the poster.
	Name *string `json:"name,omitempty"`

	// Password Password used to delete or edit the reply.
	Password *string `json:"password,omitempty"`

	// Sage Replaces email with 'rabbia' and prevents bumping the thread.
	Sage *bool `json:"sage,omitempty"`

	// Spoiler Marks attached files as spoiler.
	Spoiler *bool `json:"spoiler,omitempty"`

	// Thread ID of the thread to reply to.
	Thread int `json:"thread"`
}

Reply Reply data.

type ServerInterface

type ServerInterface interface {
	// Post reply
	// (POST /reply)
	PostReply(ctx echo.Context) error
	// Create new thread
	// (POST /thread)
	NewThread(ctx echo.Context) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) NewThread

func (w *ServerInterfaceWrapper) NewThread(ctx echo.Context) error

NewThread converts echo context to params.

func (*ServerInterfaceWrapper) PostReply

func (w *ServerInterfaceWrapper) PostReply(ctx echo.Context) error

PostReply converts echo context to params.

type SuccessResponse

type SuccessResponse struct {
	// Id ID of the submitted thread or reply
	Id int `json:"id"`
}

SuccessResponse defines model for SuccessResponse.

type Thread

type Thread struct {
	// Board Board where the thread is to be posted (e.g., 'b').
	Board string `json:"board"`

	// Body The message of the thread.
	Body *string `json:"body,omitempty"`

	// Email Email of the poster.
	Email *string `json:"email,omitempty"`

	// Embed URL for an embedded media link (YouTube, Spotify...).
	Embed *string `json:"embed,omitempty"`

	// Files Paths of the files to attach to the thread.
	Files *[]string `json:"files,omitempty"`

	// Name Name of the poster.
	Name *string `json:"name,omitempty"`

	// Password Password used to delete or edit the thread.
	Password *string `json:"password,omitempty"`

	// Sage Replaces email with 'rabbia' and prevents bumping the thread.
	Sage *bool `json:"sage,omitempty"`

	// Spoiler Marks attached files as spoiler.
	Spoiler *bool `json:"spoiler,omitempty"`

	// Subject Subject of the thread.
	Subject *string `json:"subject,omitempty"`
}

Thread Thread data.

Jump to

Keyboard shortcuts

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