engine

package
v0.0.0-...-441fb9e Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxValue

func CtxValue[T any](ctx *Context, key any) (ret T, ok bool)

func DecodeForm

func DecodeForm(r *http.Request, ptr any) error

func RegisterApi

func RegisterApi[InType, OutType any](api string, handler func(*Context, *InType) (*OutType, error), middlewares ...HandlerFunc)

func RegisterRawApi

func RegisterRawApi(api string, handler HandlerFunc, middlewares ...HandlerFunc)

func Serve

func Serve(wwwdir string, port int)

Types

type Context

type Context struct {
	RawRequest  *http.Request
	RawResponse http.ResponseWriter
	// contains filtered or unexported fields
}

func (*Context) GetValue

func (ctx *Context) GetValue(key any) (any, bool)

func (*Context) Next

func (ctx *Context) Next()

func (*Context) PutValue

func (ctx *Context) PutValue(key, value any)

type HandlerFunc

type HandlerFunc func(*Context)

func MakeAPIHandler

func MakeAPIHandler[InType, OutType any](handler func(*Context, *InType) (*OutType, error)) HandlerFunc

type Server

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

func NewServer

func NewServer(apiPrfix string) *Server

func (*Server) RegisterApi

func (s *Server) RegisterApi(api string, handler HandlerFunc, middlewares ...HandlerFunc)

func (*Server) Serve

func (s *Server) Serve(wwwdir string, port int)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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