Documentation ¶
Index ¶
- Constants
- Variables
- func BindJSON[T any](c *Context) (t *T, err error)
- func Dir(root string, listDirectory bool) http.FileSystem
- func ParseFromRequest(req *http.Request, publicKeyPath string) (uniqueUser, issuer, signature string, err error)
- func SetAuthToken(uniqueUser, issuer, privateKeyPath string, expire time.Duration) (tokenString string, err error)
- type Context
- func (c *Context) ClientIP() string
- func (c *Context) ContentType() string
- func (c *Context) Cookie(name string) (string, error)
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) DefaultPostForm(key, defaultValue string) string
- func (c *Context) DefaultQuery(key, defaultValue string) string
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) File(filepath string)
- func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
- func (c *Context) Get(key string) (value any, exists bool)
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetPostForm(key string) (string, bool)
- func (c *Context) GetPostFormArray(key string) (values []string, ok bool)
- func (c *Context) GetQuery(key string) (string, bool)
- func (c *Context) GetQueryArray(key string) (values []string, ok bool)
- func (c *Context) GetString(key string) (s string)
- func (c *Context) HTML(code int, name string, obj any)
- func (c *Context) Header(key, value string)
- func (c *Context) JSON(status int, data any) error
- func (c *Context) Param(key string) string
- func (c *Context) PostForm(key string) (value string)
- func (c *Context) PostFormArray(key string) (values []string)
- func (c *Context) Query(key string) (value string)
- func (c *Context) QueryArray(key string) (values []string)
- func (c *Context) Redirect(code int, location string)
- func (c *Context) RemoteIP() string
- func (c *Context) Render(code int, r render.Render)
- func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
- func (c *Context) Set(key string, value any)
- func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
- func (c *Context) SetSameSite(sameSite http.SameSite)
- func (c *Context) ShouldBind(obj any) error
- func (c *Context) ShouldBindJSON(obj any) error
- func (c *Context) ShouldBindWith(obj any, b binding.Binding) error
- func (c *Context) Status(code int)
- func (c *Context) Value(key any) any
- type H
- type Handler
- type HandlerFunc
- type HttpHandler
- type Middleware
- type Router
- func (r *Router) Delete(route string, handler HandlerFunc)
- func (r *Router) GET(route string, handler HandlerFunc)
- func (r *Router) Group(prefix string) *Router
- func (r *Router) HEAD(route string, handler HandlerFunc)
- func (r *Router) Method(method, route string, handler HandlerFunc)
- func (r *Router) OPTIONS(route string, handlers HandlerFunc)
- func (r *Router) POST(route string, handler HandlerFunc)
- func (r *Router) Patch(route string, handler HandlerFunc)
- func (r *Router) Put(route string, handler HandlerFunc)
- func (r *Router) Static(relativePath, root string) *Router
- func (r *Router) StaticFS(relativePath string, fs http.FileSystem) *Router
- func (r *Router) StaticFile(relativePath, filepath string) *Router
- func (r *Router) Use(middlewares ...Middleware)
- type RouterHandler
- type ServerBase
- type ServerFinalizerFunc
- type ServerOption
- type Service
- type Water
Constants ¶
View Source
const ContextKey = "_go-water/context-key"
View Source
const Version = "v0.8.6"
Variables ¶
View Source
var MaxMultipartMemory int64 = 32 << 20 // 32 MB
Functions ¶
func Dir ¶ added in v0.6.0
func Dir(root string, listDirectory bool) http.FileSystem
Dir returns a http.FileSystem that can be used by http.FileServer(). It is used internally in router.Static(). if listDirectory == true, then it works the same as http.Dir() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.
Types ¶
type Context ¶ added in v0.5.0
type Context struct { Request *http.Request Writer http.ResponseWriter Keys map[string]any // contains filtered or unexported fields }
func (*Context) ContentType ¶ added in v0.8.4
func (*Context) Deadline ¶ added in v0.5.0
Deadline returns that there is no deadline (ok==false) when c.Request has no Context.
func (*Context) DefaultPostForm ¶ added in v0.8.6
func (*Context) DefaultQuery ¶ added in v0.8.6
func (*Context) Done ¶ added in v0.5.0
func (c *Context) Done() <-chan struct{}
Done returns nil (chan which will wait forever) when c.Request has no Context.
func (*Context) FormFile ¶ added in v0.6.0
func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
func (*Context) GetPostForm ¶ added in v0.8.6
func (*Context) GetPostFormArray ¶ added in v0.8.6
func (*Context) GetQueryArray ¶ added in v0.8.6
func (*Context) PostFormArray ¶ added in v0.8.6
func (*Context) QueryArray ¶ added in v0.8.6
func (*Context) SaveUploadedFile ¶ added in v0.6.0
func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
func (*Context) SetSameSite ¶ added in v0.7.0
func (*Context) ShouldBind ¶ added in v0.8.2
func (*Context) ShouldBindJSON ¶ added in v0.5.0
func (*Context) ShouldBindWith ¶ added in v0.5.0
type Handler ¶
type Handler interface { ServerWater(ctx context.Context, req any) (any, error) GetLogger() *slog.Logger }
func NewHandler ¶
func NewHandler(srv Service, options ...ServerOption) Handler
type HandlerFunc ¶ added in v0.5.0
type HandlerFunc func(*Context)
type Middleware ¶ added in v0.6.0
type Middleware func(HandlerFunc) HandlerFunc
type Router ¶ added in v0.5.0
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Delete ¶ added in v0.8.0
func (r *Router) Delete(route string, handler HandlerFunc)
func (*Router) GET ¶ added in v0.6.0
func (r *Router) GET(route string, handler HandlerFunc)
func (*Router) HEAD ¶ added in v0.6.0
func (r *Router) HEAD(route string, handler HandlerFunc)
func (*Router) Method ¶ added in v0.5.0
func (r *Router) Method(method, route string, handler HandlerFunc)
func (*Router) OPTIONS ¶ added in v0.8.0
func (r *Router) OPTIONS(route string, handlers HandlerFunc)
func (*Router) POST ¶ added in v0.6.0
func (r *Router) POST(route string, handler HandlerFunc)
func (*Router) Patch ¶ added in v0.8.0
func (r *Router) Patch(route string, handler HandlerFunc)
func (*Router) Put ¶ added in v0.8.0
func (r *Router) Put(route string, handler HandlerFunc)
func (*Router) StaticFS ¶ added in v0.6.0
func (r *Router) StaticFS(relativePath string, fs http.FileSystem) *Router
func (*Router) StaticFile ¶ added in v0.6.0
func (*Router) Use ¶ added in v0.5.0
func (r *Router) Use(middlewares ...Middleware)
type RouterHandler ¶ added in v0.8.0
type RouterHandler struct {
// contains filtered or unexported fields
}
func (*RouterHandler) ServeHTTP ¶ added in v0.8.0
func (r *RouterHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type ServerBase ¶ added in v0.0.12
type ServerBase struct {
// contains filtered or unexported fields
}
func (*ServerBase) GetLogger ¶ added in v0.0.18
func (s *ServerBase) GetLogger() *slog.Logger
func (*ServerBase) Name ¶ added in v0.0.12
func (s *ServerBase) Name(srv Service) string
func (*ServerBase) SetLogger ¶ added in v0.0.19
func (s *ServerBase) SetLogger(l *slog.Logger)
type ServerFinalizerFunc ¶
type ServerOption ¶
type ServerOption func(h *handler)
func ServerBreaker ¶ added in v0.3.3
func ServerBreaker(breaker *gobreaker.CircuitBreaker) ServerOption
func ServerFinalizer ¶ added in v0.0.5
func ServerFinalizer(f ...ServerFinalizerFunc) ServerOption
func ServerLimiter ¶ added in v0.3.0
func ServerLimiter(interval time.Duration, b int) ServerOption
Source Files ¶
Click to show internal directories.
Click to hide internal directories.