api

package
v0.0.0-...-d987ce3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxBodySize = 32 * 1024 // 32 Ko
)

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(err error) error

func Body

func Body(rr Renderer, to any) (int, error)

func InternalServerError

func InternalServerError(err error) error

func New

func New(p *Params) (*implManager, error)

func StatusError

func StatusError(err error, status int) error

Types

type HandlerFunc

type HandlerFunc func(Renderer) error

type Manager

type Manager interface {
	Router
	Logger() *logger.Logger
	Mux() Router
	JSON(fn HandlerFunc) http.HandlerFunc
	XML(fn HandlerFunc) http.HandlerFunc
	YAML(fn HandlerFunc) http.HandlerFunc
}

type Params

type Params struct {
	Logger      *logger.Logger // Required
	MaxBodySize int64
}

type Renderer

type Renderer interface {
	http.ResponseWriter
	Request() *http.Request
	MaxBodySize() int64
	NoContent()
	WriteData(status int, data any)
}

type Router

type Router interface {
	Connect(pattern string, fn http.HandlerFunc)
	Delete(pattern string, fn http.HandlerFunc)
	Get(pattern string, fn http.HandlerFunc)
	Head(pattern string, fn http.HandlerFunc)
	Options(pattern string, fn http.HandlerFunc)
	Patch(pattern string, fn http.HandlerFunc)
	Post(pattern string, fn http.HandlerFunc)
	Put(pattern string, fn http.HandlerFunc)
	Trace(pattern string, fn http.HandlerFunc)
	Mount(pattern string, handler http.Handler)
	Use(middlewares ...func(http.Handler) http.Handler)
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳