endpoint

package
v0.0.0-...-5bd2967 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET    httpVerb = "GET"
	POST   httpVerb = "POST"
	PUT    httpVerb = "PUT"
	PATCH  httpVerb = "PATCH"
	DELETE httpVerb = "DELETE"
)

Variables

This section is empty.

Functions

func Delete

func Delete(path string) endpointPath

func Echo

func Echo[C, P, Q, B any, D dataer](p endpointPath, d OpenAPIRouteDescriber, next Endpoint[C, P, Q, B, D]) (string, string, echo.HandlerFunc)

func EchoWithContext

func EchoWithContext[C, P, Q, B any, D dataer](p endpointPath, d OpenAPIRouteDescriber, next EndpointWithContext[C, P, Q, B, D, echo.Context], opts ...echoOptions) (string, string, echo.HandlerFunc)

func EchoWithNoResponse

func EchoWithNoResponse[C, P, Q, B any, D dataer](p endpointPath, d OpenAPIRouteDescriber, next EndpointWithContext[C, P, Q, B, D, echo.Context], opts ...echoOptions) (string, string, echo.HandlerFunc)

func Fiber

func Fiber[C, P, Q, B any, D dataer](p endpointPath, d OpenAPIRouteDescriber, next Endpoint[C, P, Q, B, D]) (string, string, fiber.Handler)

func Find

func Find[T comparable](a []T, x T) (T, bool)

func Get

func Get(path string) endpointPath

func Gorilla

func Gorilla[C, P, Q, B any, D dataer](p endpointPath, d OpenAPIRouteDescriber, next Endpoint[C, P, Q, B, D]) (string, string, http.HandlerFunc)

func Patch

func Patch(path string) endpointPath

func Post

func Post(path string) endpointPath

func Put

func Put(path string) endpointPath

func WithEchoResponseSkipper

func WithEchoResponseSkipper(s EchoSkipper) echoOptions

func WithRestoredBody

func WithRestoredBody() echoOptions

Types

type CollectionDetail

type CollectionDetail struct {
	// The number of items in this result set
	CurrentItemCount int64 `json:"currentItemCount" example:"1"`
	// The number of items in the result
	ItemsPerPage int64 `json:"itemsPerPage" example:"10"`
	// The index of the first item in data.items
	StartIndex int64 `json:"startIndex" example:"1"`
	// The total number of items available in this set
	TotalItems int64 `json:"totalItems" example:"100"`
	// The index of the current page of items
	PageIndex int64 `json:"pageIndex" example:"1"`
	// The total number of pages in the result set.
	TotalPages int64 `json:"totalPages" example:"10"`
}

type CollectionItemData

type CollectionItemData[T any] struct {
	DataDetail
	Items []T `json:"items"`
	CollectionDetail
}

type DataDetail

type DataDetail struct {
	// The kind property serves as a guide to what type of information this particular object stores
	Kind string `json:"kind" example:"resource"`
	// Indicates the language of the rest of the properties in this object (BCP 47)
	Language string `json:"lang,omitempty" example:"pt-br"`
}

type DataResponse

type DataResponse[T dataer] struct {
	// Client sets this value and server echos data in the response
	Context string `json:"context,omitempty"`
	Data    T      `json:"data"`
}

type EchoSkipper

type EchoSkipper func(c echo.Context) bool

type Endpoint

type Endpoint[C, P, Q, B any, D dataer] func(EndpointInput[C, P, Q, B]) (DataResponse[D], error)

type EndpointInput

type EndpointInput[C, P, Q, B any] struct {
	Claims C
	Params P
	Query  Q
	Body   B
}

type EndpointWithContext

type EndpointWithContext[C, P, Q, B any, D dataer, Context any] func(EndpointInput[C, P, Q, B], Context) (DataResponse[D], error)

type OpenAPI

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

func NewOpenAPI

func NewOpenAPI(title, version string) OpenAPI

func (*OpenAPI) AddJWTBearerAuth

func (op *OpenAPI) AddJWTBearerAuth(name string) *openapi3.T

func (*OpenAPI) AddServer

func (op *OpenAPI) AddServer(url, description string) *openapi3.T

func (*OpenAPI) Describe

func (op *OpenAPI) Describe(description string)

func (*OpenAPI) Route

func (op *OpenAPI) Route(title, description string) OpenAPIRouteDescriber

func (*OpenAPI) RouteGroup

func (op *OpenAPI) RouteGroup(name string, description ...string) OpenAPIRouteGroup

func (*OpenAPI) T

func (op *OpenAPI) T() *openapi3.T

type OpenAPIRouteDescriber

type OpenAPIRouteDescriber func(func(RouteDescription, *openapi3.T))

type OpenAPIRouteGroup

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

func (*OpenAPIRouteGroup) Route

func (g *OpenAPIRouteGroup) Route(title, description string) OpenAPIRouteDescriber

type RouteDescription

type RouteDescription struct {
	Title       string
	Description string
	Tag         string
}

type SchemaRepo

type SchemaRepo struct {
	Start *openapi3.Schema
	Repo  map[string]*openapi3.Schema
}

type Schemaer

type Schemaer interface {
	Schema() SchemaRepo
}

type SingleItemData

type SingleItemData[T any] struct {
	DataDetail
	Item T `json:"item"`
}

Jump to

Keyboard shortcuts

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