Documentation
¶
Index ¶
- func App(cfg *Config, controllers ...Controller)
- func StartStop(startFunc, stopFunc func())
- type Config
- type Controller
- type Core
- func (r Core) DELETE(p string, fn Handler, m ...Middleware)
- func (r Core) GET(p string, fn Handler, m ...Middleware)
- func (c *Core) GetCfgFileServerAndRun()
- func (r Core) Handle(method string, p string, fn Handler, m ...Middleware)
- func (c *Core) MergeGroup(group *Group)
- func (c *Core) NewGroup(prefix string) *Group
- func (r Core) PATCH(p string, fn Handler, m ...Middleware)
- func (r Core) POST(p string, fn Handler, m ...Middleware)
- func (r Core) PUT(p string, fn Handler, m ...Middleware)
- func (c *Core) ServeFiles(path string, root http.FileSystem)
- func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *Core) Start()
- func (c *Core) Stop() error
- type CoreMiddleware
- type DefaultMiddlewareSession
- type DefaultMiddlewareToken
- type ErrorHandler
- type ErrorHttpHandler
- type Errors
- type Group
- func (g *Group) AddRequestMiddleware(add Middleware)
- func (g *Group) AddResponseMiddleware(add Middleware)
- func (g *Group) DELETE(path string, fn Handler, m ...Middleware)
- func (g *Group) GET(path string, fn Handler, m ...Middleware)
- func (g *Group) PATCH(path string, fn Handler, m ...Middleware)
- func (g *Group) POST(path string, fn Handler, m ...Middleware)
- func (g *Group) PUT(path string, fn Handler, m ...Middleware)
- type Handler
- type Middleware
- type MiddlewarePre
- type Multiplexor
- type MultiplexorJulienschmidtHttpRouter
- func (m *MultiplexorJulienschmidtHttpRouter) Handle(method string, path string, fn Handler)
- func (m *MultiplexorJulienschmidtHttpRouter) Init(c *Core) error
- func (m *MultiplexorJulienschmidtHttpRouter) ServeFiles(patch string, dir http.FileSystem)
- func (m *MultiplexorJulienschmidtHttpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Param
- type Provider
- func (c *Provider) Close()
- func (c *Provider) GetConfig() Config
- func (c *Provider) GetCookie(name string) (*http.Cookie, error)
- func (c *Provider) GetStatusCode() int
- func (c *Provider) Header() http.Header
- func (p *Provider) Param(key string) string
- func (c *Provider) PostFormValue(name string) string
- func (c *Provider) SetCookie(Cookie *http.Cookie)
- func (c *Provider) SetStatusCode(status int)
- func (c *Provider) WriteHtml(status int, html string) error
- func (c *Provider) WriteJson(status int, in interface{}) error
- func (c *Provider) WriteRaw(status int, contentType string, val []byte) error
- type Services
- type TokenService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func App ¶
func App(cfg *Config, controllers ...Controller)
Types ¶
type Config ¶
type Config struct {
Server struct {
Protocol string
Http struct {
Addr string
}
Https struct {
Addr string
Tls struct {
CertFile string
KeyFile string
}
}
Timeout struct {
Read int64
ReadHeader int64
Write int64
Idle int64
StopServer int64
}
FileServer struct {
Used bool
SearchFileIfError404 bool
PathPrefix, Dir string
}
}
Token struct {
Backend string
CookieName string
CryptAES struct {
//The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
SecretKeyNext, SecretKeyPrevious string
}
JoseSign struct {
SecretKeyNext, SecretKeyPrevious string
// https://pkg.go.dev/github.com/dvsekhvalnov/jose2go@v1.5.0?utm_source=gopls#Sign
Algorithm string
Compress bool
}
JoseCrypt struct {
SecretKeyNext, SecretKeyPrevious string
// https://pkg.go.dev/github.com/dvsekhvalnov/jose2go@v1.5.0?utm_source=gopls#Encrypt
Alg, Enc string
Compress bool
}
}
Sessions struct {
Backend string
Ram struct {
Expiries int64
CleanupInterval int64
IsSnapshot bool
SnapshotFile string
SnapshotInterval int64
}
}
Cache struct {
Backend string
Freecache struct {
BytesMaxSize int
}
}
Renderer struct {
Dir string
Suffix string
}
Error struct {
Display bool
}
Log struct {
// trace, debug, info, warn, error, fatal, panic
// https://pkg.go.dev/github.com/sirupsen/logrus?utm_source=godoc#Level
Level string
//json else text
Format string
// write log to file
File string
Stdout bool
}
}
func (*Config) SetDefaultValuesAndVAlidateRequire ¶
func (cfg *Config) SetDefaultValuesAndVAlidateRequire()
type Controller ¶
type Core ¶
type Core struct {
Errors *Errors
Middlewares struct {
Token CoreMiddleware
Session CoreMiddleware
}
Log logger.Logger
Services *Services
// contains filtered or unexported fields
}
func (Core) DELETE ¶
func (r Core) DELETE(p string, fn Handler, m ...Middleware)
func (Core) GET ¶
func (r Core) GET(p string, fn Handler, m ...Middleware)
func (*Core) GetCfgFileServerAndRun ¶
func (c *Core) GetCfgFileServerAndRun()
func (*Core) MergeGroup ¶
func (Core) PATCH ¶
func (r Core) PATCH(p string, fn Handler, m ...Middleware)
func (Core) POST ¶
func (r Core) POST(p string, fn Handler, m ...Middleware)
func (Core) PUT ¶
func (r Core) PUT(p string, fn Handler, m ...Middleware)
func (*Core) ServeFiles ¶
func (c *Core) ServeFiles(path string, root http.FileSystem)
type CoreMiddleware ¶
type DefaultMiddlewareSession ¶
type DefaultMiddlewareSession struct {
}
func (*DefaultMiddlewareSession) Request ¶
func (s *DefaultMiddlewareSession) Request(h Handler) Handler
func (*DefaultMiddlewareSession) Response ¶
func (s *DefaultMiddlewareSession) Response(h Handler) Handler
type DefaultMiddlewareToken ¶
type DefaultMiddlewareToken struct {
}
func (*DefaultMiddlewareToken) Request ¶
func (s *DefaultMiddlewareToken) Request(h Handler) Handler
func (*DefaultMiddlewareToken) Response ¶
func (s *DefaultMiddlewareToken) Response(h Handler) Handler
func (*DefaultMiddlewareToken) UnmarshalIfNew ¶
func (s *DefaultMiddlewareToken) UnmarshalIfNew(p *Provider, val string)
type ErrorHandler ¶
type ErrorHandler func(*Core, http.ResponseWriter, *http.Request)
func (ErrorHandler) ToHttpHandler ¶
func (er ErrorHandler) ToHttpHandler(c *Core) http.Handler
type ErrorHttpHandler ¶
type ErrorHttpHandler struct {
// contains filtered or unexported fields
}
func (*ErrorHttpHandler) ServeHTTP ¶
func (er *ErrorHttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Errors ¶
type Errors struct {
NotFound ErrorHandler
MethodNotAllowed ErrorHandler
PanicHandler func(*Core, http.ResponseWriter, *http.Request, interface{})
ErrorHandler func(*Core, http.ResponseWriter, *http.Request, error)
}
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) AddRequestMiddleware ¶
func (g *Group) AddRequestMiddleware(add Middleware)
func (*Group) AddResponseMiddleware ¶
func (g *Group) AddResponseMiddleware(add Middleware)
type Middleware ¶
type MiddlewarePre ¶
type MiddlewarePre func(http.HandlerFunc) http.HandlerFunc
type Multiplexor ¶
type MultiplexorJulienschmidtHttpRouter ¶
type MultiplexorJulienschmidtHttpRouter struct {
// contains filtered or unexported fields
}
func (*MultiplexorJulienschmidtHttpRouter) Handle ¶
func (m *MultiplexorJulienschmidtHttpRouter) Handle(method string, path string, fn Handler)
func (*MultiplexorJulienschmidtHttpRouter) Init ¶
func (m *MultiplexorJulienschmidtHttpRouter) Init(c *Core) error
func (*MultiplexorJulienschmidtHttpRouter) ServeFiles ¶
func (m *MultiplexorJulienschmidtHttpRouter) ServeFiles(patch string, dir http.FileSystem)
func (*MultiplexorJulienschmidtHttpRouter) ServeHTTP ¶
func (m *MultiplexorJulienschmidtHttpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Provider ¶
type Provider struct {
Log *Logger
Context context.Context
Token *token.Token
Session *values.Value
Cache cache.CacheInterface
WriterBuff *bytes.Buffer
Services *Services
// contains filtered or unexported fields
}
func (*Provider) GetStatusCode ¶
func (*Provider) PostFormValue ¶
func (*Provider) SetStatusCode ¶
type Services ¶
type Services struct {
Token TokenService
Sessions sessions.Session
Cache *cache.Cache
Multiplexor Multiplexor
}
type TokenService ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.