api

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth added in v0.3.0

func Auth(providerNames ...string) opt.Option[Options]

func Description added in v0.4.1

func Description(description string) opt.Option[Options]

func ErrorConverter

func ErrorConverter(impl func(err error) error) opt.Option[Config]

func NoOpErrorConverter

func NoOpErrorConverter(err error) error

func Oauth2 added in v0.3.0

func Oauth2(providerName string, scopes ...string) opt.Option[Options]

func OperationID added in v0.4.1

func OperationID(operationID string) opt.Option[Options]

func Tags

func Tags(tags ...string) opt.Option[Options]

Types

type Config

type Config struct {
	ErrorConverter func(err error) error
}

func DefaultConfig

func DefaultConfig() *Config

func NewConfig

func NewConfig(opts ...opt.Option[Config]) *Config

type Created

type Created struct {
	Id uuid.UUID `json:"id"`
}

type Handler

type Handler struct {
	Options Options
	Mount   func(api huma.API, config Config)
}

func NewHandler

func NewHandler[Request any, Response any](
	method http.Method,
	path string,
	impl func(ctx context.Context, request *Request) (*Response, error),
	opts ...opt.Option[Options],
) *Handler

type Options

type Options struct {
	Method          http.Method
	Path            string
	RegisterOas3    bool
	OperationId     string
	ContentType     string
	Tags            []string
	Protected       bool
	AuthProviders   []string
	OAuth2Providers map[string][]string
	Description     string
}

type Response

type Response[T any] struct {
	Body T
}

func Forbidden

func Forbidden[T any](msg string, err error) (*Response[T], error)

func NotFound

func NotFound[T any](msg string) (*Response[T], error)

func NotImplemented

func NotImplemented[T any](format string, args ...any) (*Response[T], error)

func Ok

func Ok[T any](body T) (*Response[T], error)

func OkCreated

func OkCreated(id uuid.UUID) (*Response[Created], error)

func Unauthorized

func Unauthorized[T any](msg string, err error) (*Response[T], error)

Jump to

Keyboard shortcuts

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