gotrac

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func P

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

Types

type Handler

type Handler interface {
	http.Handler
	Info() *HandlerInformation
}

type HandlerInformation

type HandlerInformation struct {
	Information
	Input  *HandlerType
	Output *HandlerType
	Hidden bool
}

type HandlerType

type HandlerType struct {
	GoType   reflect.Type
	HttpType []string
}

func Binary

func Binary(mimeTypes ...string) *HandlerType

func File

func File() *HandlerType

func Json

func Json[T any]() *HandlerType

type Information

type Information struct {
	Summary     string
	Description string
}

func (*Information) WithDescription added in v0.0.4

func (c *Information) WithDescription(description string) *Information

func (*Information) WithSummary added in v0.0.4

func (c *Information) WithSummary(summary string) *Information

type Mux

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

func (*Mux) Find

func (m *Mux) Find(rctx *chi.Context, method, path string) string

func (*Mux) Group

func (m *Mux) Group(fn func(r Router)) Router

func (*Mux) Handle

func (m *Mux) Handle(pattern string, h Handler) Route

func (*Mux) HandleFunc

func (m *Mux) HandleFunc(pattern string, h http.HandlerFunc) Route

func (*Mux) Info added in v0.0.4

func (m *Mux) Info() *RouterInformation

func (*Mux) Match

func (m *Mux) Match(rctx *chi.Context, method, path string) bool

func (*Mux) Method

func (m *Mux) Method(method, pattern string, h Handler) Route

func (*Mux) MethodFunc

func (m *Mux) MethodFunc(method, pattern string, h http.HandlerFunc) Route

func (*Mux) MethodNotAllowed

func (m *Mux) MethodNotAllowed(h http.HandlerFunc)

func (*Mux) Middlewares

func (m *Mux) Middlewares() chi.Middlewares

func (*Mux) Mount

func (m *Mux) Mount(pattern string, h http.Handler)

func (*Mux) NotFound

func (m *Mux) NotFound(h http.HandlerFunc)

func (*Mux) Route

func (m *Mux) Route(pattern string, fn func(r Router)) Router

func (*Mux) Routes

func (m *Mux) Routes() []chi.Route

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*Mux) Use

func (m *Mux) Use(middlewares ...func(http.Handler) http.Handler)

func (*Mux) With

func (m *Mux) With(middlewares ...func(http.Handler) http.Handler) Router

func (*Mux) WithInfo added in v0.0.4

func (m *Mux) WithInfo(fn func(info *RouterInformation)) Router

type Route

type Route interface {
	Handler
	WithInfo(fn func(route *RouteInformation)) Route
}

type RouteInformation added in v0.0.4

type RouteInformation HandlerInformation

func (*RouteInformation) WithDescription added in v0.0.4

func (c *RouteInformation) WithDescription(description string) *RouteInformation

func (*RouteInformation) WithHidden added in v0.0.4

func (c *RouteInformation) WithHidden(hidden bool) *RouteInformation

func (*RouteInformation) WithInput added in v0.0.4

func (c *RouteInformation) WithInput(typ *HandlerType) *RouteInformation

func (*RouteInformation) WithOutput added in v0.0.4

func (c *RouteInformation) WithOutput(typ *HandlerType) *RouteInformation

func (*RouteInformation) WithSummary added in v0.0.4

func (c *RouteInformation) WithSummary(summary string) *RouteInformation

type Router

type Router interface {
	http.Handler
	chi.Routes

	// Use appends one or more middlewares onto the Router stack.
	Use(middlewares ...func(http.Handler) http.Handler)

	// With adds inline middlewares for an endpoint handler.
	With(middlewares ...func(http.Handler) http.Handler) Router

	// Group adds a new inline-Router along the current routing
	// path, with a fresh middleware stack for the inline-Router.
	Group(fn func(r Router)) Router

	// Route mounts a sub-Router along a `pattern“ string.
	Route(pattern string, fn func(r Router)) Router

	// Mount attaches another http.Handler along ./pattern/*
	Mount(pattern string, h http.Handler)

	// Handle and HandleFunc adds routes for `pattern` that matches
	// all HTTP methods.
	Handle(pattern string, h Handler) Route
	HandleFunc(pattern string, h http.HandlerFunc) Route

	// Method and MethodFunc adds routes for `pattern` that matches
	// the `method` HTTP method.
	Method(method, pattern string, h Handler) Route
	MethodFunc(method, pattern string, h http.HandlerFunc) Route

	// NotFound defines a handler to respond whenever a route could
	// not be found.
	NotFound(h http.HandlerFunc)

	// MethodNotAllowed defines a handler to respond whenever a method is
	// not allowed.
	MethodNotAllowed(h http.HandlerFunc)

	// ++++ Information ++++
	Info() *RouterInformation
	WithInfo(fn func(info *RouterInformation)) Router
}

Router consisting of the gotrac routing methods used by chi's Mux, using only the standard net/http.

func Default

func Default() Router

Default creates a new Router and adds the IdMiddleware required for error handling

func NewRouter added in v0.0.4

func NewRouter() Router

type RouterInformation

type RouterInformation struct {
	Information
}

func (*RouterInformation) WithDescription added in v0.0.4

func (c *RouterInformation) WithDescription(description string) *RouterInformation

func (*RouterInformation) WithSummary added in v0.0.4

func (c *RouterInformation) WithSummary(summary string) *RouterInformation

Jump to

Keyboard shortcuts

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