Documentation
¶
Index ¶
- Variables
- func CreateApp(fn AppContextFunc, sArr ...*http.Server) *httpServers
- type AppContext
- func (c *AppContext) Controller(path string, fn DefaultControllerFunc, midWares ...MidWare)
- func (c AppContext) Header(key, value string)
- func (c AppContext) MaxBodySize(maxBodySize int64)
- func (c *AppContext) Static(path string, dir string, fn DefaultControllerFunc)
- func (c AppContext) Use(fn ...MidWare)
- func (c *AppContext) UseGlobal(fn ...MidWare)
- type AppContextFunc
- type ControllerHandler
- type Ctx
- func (c *Ctx) BodyParser(i any) error
- func (c *Ctx) Cookie(name string) (*http.Cookie, error)
- func (c *Ctx) DtoParser(i IDto) error
- func (c *Ctx) Error(statusCode int, message any) error
- func (c *Ctx) Flush() error
- func (c *Ctx) Req() *Request
- func (c *Ctx) Res() *Response
- func (c *Ctx) Send(v any) error
- func (c *Ctx) SendFile(f string) error
- func (c *Ctx) SendString(s string) error
- func (c *Ctx) Session() *Session
- func (c *Ctx) SetCookie(name, value, path, domain string, maxAge int, secure, httpOnly bool)
- type DefaultController
- func (c *DefaultController) Connect(path string, ef *EndFunc)
- func (c *DefaultController) Delete(path string, ef *EndFunc)
- func (c *DefaultController) Get(path string, ef *EndFunc)
- func (c *DefaultController) Head(path string, ef *EndFunc)
- func (c DefaultController) Header(key, value string)
- func (c DefaultController) MaxBodySize(maxBodySize int64)
- func (c *DefaultController) Options(path string, ef *EndFunc)
- func (c *DefaultController) Patch(path string, ef *EndFunc)
- func (c *DefaultController) Post(path string, ef *EndFunc)
- func (c *DefaultController) Put(path string, ef *EndFunc)
- func (c *DefaultController) Redirect(code int, location string)
- func (c *DefaultController) Sse()
- func (c *DefaultController) Trace(path string, ef *EndFunc)
- func (c DefaultController) Use(fn ...MidWare)
- type DefaultControllerFunc
- type EndFunc
- type IDto
- type MidWare
- type Request
- type Response
- type Session
- type StaticServerConfig
Constants ¶
This section is empty.
Variables ¶
var SessionStorage sync.Map
SessionStore holds all sessions
Functions ¶
func CreateApp ¶
func CreateApp(fn AppContextFunc, sArr ...*http.Server) *httpServers
Create NestGO App from nest factory
Types ¶
type AppContext ¶
type AppContext struct {
// contains filtered or unexported fields
}
func (*AppContext) Controller ¶
func (c *AppContext) Controller(path string, fn DefaultControllerFunc, midWares ...MidWare)
Default Controller - Here you can override the default middlewares for this controller and assign your own.
func (AppContext) MaxBodySize ¶
func (c AppContext) MaxBodySize(maxBodySize int64)
func (*AppContext) Static ¶
func (c *AppContext) Static(path string, dir string, fn DefaultControllerFunc)
Static Server Controller
func (AppContext) Use ¶
func (c AppContext) Use(fn ...MidWare)
Add middlewares for each level of application
func (*AppContext) UseGlobal ¶
func (c *AppContext) UseGlobal(fn ...MidWare)
Add the middleware globally, but it will still depend on where you are going to use it. At the global level or at the level of several controllers.
type AppContextFunc ¶
type AppContextFunc func(c *AppContext)
type ControllerHandler ¶
type ControllerHandler func(*Ctx, *handler)
type Ctx ¶
type Ctx struct {
Next nextFunc
// contains filtered or unexported fields
}
Ctx represents the context with response and request methods
func (*Ctx) BodyParser ¶
Regular body parser based on the Content-Type header
func (*Ctx) DtoParser ¶
Regular body parser + auto validation from struct method, based on the Content-Type header
func (*Ctx) Error ¶
Error handles errors based on content type and message type HTTP 200 don't send message from this function
type DefaultController ¶
type DefaultController struct {
// contains filtered or unexported fields
}
func (*DefaultController) Connect ¶
func (c *DefaultController) Connect(path string, ef *EndFunc)
func (*DefaultController) Delete ¶
func (c *DefaultController) Delete(path string, ef *EndFunc)
func (*DefaultController) Get ¶
func (c *DefaultController) Get(path string, ef *EndFunc)
func (*DefaultController) Head ¶
func (c *DefaultController) Head(path string, ef *EndFunc)
func (DefaultController) MaxBodySize ¶
func (c DefaultController) MaxBodySize(maxBodySize int64)
func (*DefaultController) Options ¶
func (c *DefaultController) Options(path string, ef *EndFunc)
func (*DefaultController) Patch ¶
func (c *DefaultController) Patch(path string, ef *EndFunc)
func (*DefaultController) Post ¶
func (c *DefaultController) Post(path string, ef *EndFunc)
func (*DefaultController) Put ¶
func (c *DefaultController) Put(path string, ef *EndFunc)
func (*DefaultController) Redirect ¶
func (c *DefaultController) Redirect(code int, location string)
func (*DefaultController) Sse ¶
func (c *DefaultController) Sse()
func (*DefaultController) Trace ¶
func (c *DefaultController) Trace(path string, ef *EndFunc)
type DefaultControllerFunc ¶
type DefaultControllerFunc func(c *DefaultController)
type Session ¶
Session represents a user session
func (*Session) SetExpiration ¶
SetExpiration sets the expiration time for the session