presentation

package
v0.0.0-...-98a7bba Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DecoderFn

type DecoderFn func(ctx app.Context, w http.ResponseWriter, req *http.Request, route Route) (any, error)

type EncoderFn

type EncoderFn func(ctx app.Context, w http.ResponseWriter, response response.Response, route Route) error

type EndpointFn

type EndpointFn func(ctx app.Context, resource any) (response.Response, error)

type HandlerFn

type HandlerFn func(ctx app.Context, w http.ResponseWriter, req *http.Request) error

type MiddlewareFn

type MiddlewareFn func(h HandlerFn, route Route) HandlerFn

type ResourceConfig

type ResourceConfig interface {
	Attributes() any
	Relationships() any
}

type Route

type Route interface {
	Path() string
	ResourceConfig() ResourceConfig
	Method() string
	Decoder() DecoderFn
	Endpoint() EndpointFn
	Encoder() EncoderFn
}

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) Build

func (r *Router) Build(ctx app.Context) *Router

func (*Router) Register

func (r *Router) Register(ctx app.Context, routes []Route) *Router

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) Use

func (r *Router) Use(handler MiddlewareFn) *Router

Jump to

Keyboard shortcuts

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