gotrac

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 12 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 Generator

type Generator interface {
	Generate(router Router) (*openapi31.Spec, error)
}

func NewGenerator

func NewGenerator() Generator

type Handler

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

type HandlerInformation

type HandlerInformation interface {
	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 interface {
	Summary() string
	Description() string
}

type Mux

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

func (*Mux) Description

func (m *Mux) Description() string

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) 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) Summary

func (m *Mux) Summary() string

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) WithDescription

func (m *Mux) WithDescription(description string) Router

func (*Mux) WithDocs

func (m *Mux) WithDocs(pattern string, generator Generator)

func (*Mux) WithSummary

func (m *Mux) WithSummary(title string) Router

func (*Mux) WithSwaggerUI

func (m *Mux) WithSwaggerUI(pattern string, docPattern string, title string, config *swg.Config)

type Route

type Route interface {
	HandlerInformation
	WithSummary(summary string) Route
	WithDescription(description string) Route
	ForInput(fluent func(typ *HandlerType)) Route
	ForOutput(fluent func(typ *HandlerType)) Route
	WithInput(typ *HandlerType) Route
	WithOutput(typ *HandlerType) Route
	WithHidden(hidden bool) Route
}

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)

	WithDocs(pattern string, generator Generator)
	WithSwaggerUI(pattern string, docPattern string, title string, config *swg.Config)

	// ++++ Information ++++
	RouterInformation
	WithSummary(summary string) Router
	WithDescription(description string) 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

type RouterInformation

type RouterInformation interface {
	Information
}

Jump to

Keyboard shortcuts

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