Documentation
¶
Index ¶
- Constants
- Variables
- func ToGinHandlerFunc(digestAuth *DigestAuth, handlers ...HandlerFunc) []gin.HandlerFunc
- func ToGinHandlerRawFunc(digestAuth *DigestAuth, handlers ...HandlerRawFunc) []gin.HandlerFunc
- func User[T any](r *Request) (T, error)
- type Authentication
- type CertManager
- type Cookie
- func (c *Cookie) Delete(key string)
- func (c *Cookie) Expire(key string)
- func (c *Cookie) Forever(key string, value string)
- func (c *Cookie) ForeverDomain(domain string, key string, value string)
- func (c *Cookie) Get(key string) string
- func (c *Cookie) Set(key string, value string)
- func (c *Cookie) SetDomain(domain string, key string, value string)
- func (c *Cookie) SetWithExpire(key string, value string, expire int)
- func (c *Cookie) Update(key string, value string)
- type DigestAuth
- type File
- type HandlerFunc
- type HandlerRawFunc
- type HandlersChain
- type HandlersRawChain
- type HttpServer
- func (httpServer *HttpServer) Any(relativePath string, handlers ...gin.HandlerFunc)
- func (httpServer *HttpServer) Close() error
- func (httpServer *HttpServer) DELETE(relativePath string, handlers ...gin.HandlerFunc)
- func (httpServer *HttpServer) GET(relativePath string, handlers ...gin.HandlerFunc)
- func (httpServer *HttpServer) Handle(httpMethod string, relativePath string, handlers ...gin.HandlerFunc)
- func (httpServer *HttpServer) POST(relativePath string, handlers ...gin.HandlerFunc)
- func (httpServer *HttpServer) PUT(relativePath string, handlers ...gin.HandlerFunc)
- func (httpServer *HttpServer) Port() int
- func (httpServer *HttpServer) Run() error
- func (httpServer *HttpServer) Use(handlers ...gin.HandlerFunc)
- type JsonObject
- type MemFileSystem
- type Message
- func Data(data any) *Message
- func DataCode(code int, data any) *Message
- func DataType(t string, data any) *Message
- func Error(err ...error) *Message
- func ErrorMessage(msg ...string) *Message
- func Errors(data any, msg ...error) *Message
- func Ok(msg ...string) *Message
- func Redirect(url string) *Message
- func Unauthorized(data any, msg ...error) *Message
- type NoLoginError
- type Page
- type PageAble
- type Request
- func (r *Request) Abort()
- func (r *Request) BindJSON(value any) error
- func (r *Request) Cookie() *Cookie
- func (r *Request) Domain() string
- func (r *Request) FormParamsPage() (*Page, error)
- func (r *Request) FullPath() string
- func (r *Request) GetDigestAuth() *DigestAuth
- func (r *Request) GetFormParam(key string) string
- func (r *Request) GetIntFormParam(key string) int
- func (r *Request) GetIntFormParamOrDefault(key string, defaultValue int) int
- func (r *Request) GetJsonIntValue(key string) (int, error)
- func (r *Request) GetJsonIntValueOrDefault(key string, defaultValue int) int
- func (r *Request) GetJsonStringValue(key string) (string, error)
- func (r *Request) GetJsonStringValueOrDefault(key string, defaultValue string) string
- func (r *Request) GinContext() *gin.Context
- func (r *Request) IsGet() bool
- func (r *Request) IsPost() bool
- func (r *Request) JSON(code int, value any)
- func (r *Request) Json() (*JsonObject, error)
- func (r *Request) JsonPage() (*Page, error)
- func (r *Request) Message(t *Message)
- func (r *Request) Next()
- func (r *Request) Page() (*Page, error)
- func (r *Request) Param(key string) string
- func (r *Request) ParamInt(key string) int
- func (r *Request) ParamUint(key string) uint
- func (r *Request) Query(key string) string
- func (r *Request) RemoteAddr() string
- func (r *Request) SignIn(user any) (any, error)
- func (r *Request) SignOut() (any, error)
- func (r *Request) User() (any, error)
- type Response
- type ResponseWriteCloser
- type SSLConfig
- type ServerConfig
Constants ¶
View Source
const (
GetNotSupportJson = "JSON parameters are not supported in GET requests"
)
View Source
const MaxHeaderBytes = 8192
View Source
const MaxReadHeaderTimeout = time.Second * 30
View Source
const MaxReadTimeout = time.Minute * 10
View Source
const ServerConfigKey = "web.server"
Variables ¶
View Source
var NoLogin = &NoLoginError{}
Functions ¶
func ToGinHandlerFunc ¶
func ToGinHandlerFunc(digestAuth *DigestAuth, handlers ...HandlerFunc) []gin.HandlerFunc
func ToGinHandlerRawFunc ¶
func ToGinHandlerRawFunc(digestAuth *DigestAuth, handlers ...HandlerRawFunc) []gin.HandlerFunc
Types ¶
type Authentication ¶
type CertManager ¶ added in v0.1.1
type CertManager struct {
// contains filtered or unexported fields
}
func NewCertManager ¶ added in v0.1.1
func NewCertManager() *CertManager
func (*CertManager) AddHost ¶ added in v0.1.1
func (cm *CertManager) AddHost(host string)
func (*CertManager) AddPort ¶ added in v0.1.1
func (cm *CertManager) AddPort(port int)
func (*CertManager) GetCertManager ¶ added in v0.1.1
func (cm *CertManager) GetCertManager() (*autocert.Manager, error)
func (*CertManager) Start ¶ added in v0.1.1
func (cm *CertManager) Start()
type Cookie ¶
type Cookie struct {
// contains filtered or unexported fields
}
func (*Cookie) ForeverDomain ¶
type DigestAuth ¶
type DigestAuth struct {
// contains filtered or unexported fields
}
func NewDigestAuth ¶
func NewDigestAuth(authentication Authentication) *DigestAuth
func (*DigestAuth) Authentication ¶
func (digestAuth *DigestAuth) Authentication() Authentication
type HandlerFunc ¶
func AuthChecks ¶
func AuthChecks(handlers ...HandlerFunc) []HandlerFunc
type HandlerRawFunc ¶
func AuthRawChecks ¶
func AuthRawChecks(handlers ...HandlerRawFunc) []HandlerRawFunc
type HandlersChain ¶ added in v0.1.1
type HandlersChain []HandlerFunc
func Of ¶ added in v0.1.1
func Of(handlerFunc ...HandlerFunc) HandlersChain
func (HandlersChain) GetFuncName ¶ added in v0.1.1
func (c HandlersChain) GetFuncName() string
func (HandlersChain) Last ¶ added in v0.1.1
func (c HandlersChain) Last() HandlerFunc
type HandlersRawChain ¶ added in v0.1.1
type HandlersRawChain []HandlerRawFunc
func OfRaw ¶ added in v0.1.1
func OfRaw(handlerRawFunc ...HandlerRawFunc) HandlersRawChain
func (HandlersRawChain) GetFuncName ¶ added in v0.1.1
func (c HandlersRawChain) GetFuncName() string
func (HandlersRawChain) Last ¶ added in v0.1.1
func (c HandlersRawChain) Last() HandlerRawFunc
type HttpServer ¶ added in v0.1.1
type HttpServer struct {
// contains filtered or unexported fields
}
func NewHttpServer ¶ added in v0.1.1
func NewHttpServer(serverConfig *ServerConfig, certManager *CertManager) *HttpServer
func (*HttpServer) Any ¶ added in v0.1.2
func (httpServer *HttpServer) Any(relativePath string, handlers ...gin.HandlerFunc)
func (*HttpServer) Close ¶ added in v0.1.1
func (httpServer *HttpServer) Close() error
func (*HttpServer) DELETE ¶ added in v0.1.2
func (httpServer *HttpServer) DELETE(relativePath string, handlers ...gin.HandlerFunc)
func (*HttpServer) GET ¶ added in v0.1.1
func (httpServer *HttpServer) GET(relativePath string, handlers ...gin.HandlerFunc)
func (*HttpServer) Handle ¶ added in v0.1.2
func (httpServer *HttpServer) Handle(httpMethod string, relativePath string, handlers ...gin.HandlerFunc)
func (*HttpServer) POST ¶ added in v0.1.1
func (httpServer *HttpServer) POST(relativePath string, handlers ...gin.HandlerFunc)
func (*HttpServer) PUT ¶ added in v0.1.2
func (httpServer *HttpServer) PUT(relativePath string, handlers ...gin.HandlerFunc)
func (*HttpServer) Port ¶ added in v0.1.1
func (httpServer *HttpServer) Port() int
func (*HttpServer) Run ¶ added in v0.1.1
func (httpServer *HttpServer) Run() error
func (*HttpServer) Use ¶ added in v0.1.2
func (httpServer *HttpServer) Use(handlers ...gin.HandlerFunc)
type JsonObject ¶
func (JsonObject) GetInt ¶
func (o JsonObject) GetInt(key string) int
func (JsonObject) GetIntForDefault ¶
func (o JsonObject) GetIntForDefault(key string, defaultValue int) int
func (JsonObject) GetString ¶
func (o JsonObject) GetString(key string) string
type MemFileSystem ¶ added in v0.1.2
type MemFileSystem struct {
// contains filtered or unexported fields
}
func DefaultMemFileSystem ¶ added in v0.1.2
func DefaultMemFileSystem(serverConfig *ServerConfig) *MemFileSystem
func NewMemFileSystem ¶ added in v0.1.2
func NewMemFileSystem(cacheTime time.Duration, serverConfig *ServerConfig) *MemFileSystem
func (*MemFileSystem) Exists ¶ added in v0.1.2
func (m *MemFileSystem) Exists(name string) (bool, error)
type Message ¶
type Message struct {
Code int `json:"code"`
Data any `json:"data"`
Msg string `json:"msg"`
Type string `json:"type"`
}
func ErrorMessage ¶
func Unauthorized ¶
type NoLoginError ¶
type NoLoginError struct {
// contains filtered or unexported fields
}
func (*NoLoginError) Error ¶
func (e *NoLoginError) Error() string
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequest(c *gin.Context, digestAuth *DigestAuth) *Request
func (*Request) FormParamsPage ¶
func (*Request) GetDigestAuth ¶
func (r *Request) GetDigestAuth() *DigestAuth
func (*Request) GetFormParam ¶
func (*Request) GetIntFormParam ¶
func (*Request) GetIntFormParamOrDefault ¶
func (*Request) GetJsonIntValueOrDefault ¶
func (*Request) GetJsonStringValue ¶
func (*Request) GetJsonStringValueOrDefault ¶
func (*Request) GinContext ¶ added in v0.1.1
func (*Request) Json ¶
func (r *Request) Json() (*JsonObject, error)
func (*Request) Next ¶ added in v0.1.2
func (r *Request) Next()
Next should be used only inside middleware. It executes the pending handlers in the chain inside the calling handler. See example in GitHub.
func (*Request) Query ¶ added in v0.1.2
Query returns the keyed url query value if it exists, otherwise it returns an empty string `("")`. It is shortcut for `c.Request.URL.Query().Get(key)`
GET /path?id=1234&name=Manu&value=
c.Query("id") == "1234"
c.Query("name") == "Manu"
c.Query("value") == ""
c.Query("wtf") == ""
func (*Request) RemoteAddr ¶
type Response ¶
type Response interface {
gin.ResponseWriter
SetAttachmentFileName(fileName string)
}
type ResponseWriteCloser ¶
type ResponseWriteCloser struct {
// contains filtered or unexported fields
}
func CreateResponseWriteCloser ¶
func CreateResponseWriteCloser(response Response) *ResponseWriteCloser
func (*ResponseWriteCloser) Close ¶
func (w *ResponseWriteCloser) Close() error
type ServerConfig ¶ added in v0.1.1
func DefaultServerConfig ¶ added in v0.1.1
func DefaultServerConfig() *ServerConfig
func (*ServerConfig) SSLEnabled ¶ added in v0.1.1
func (s *ServerConfig) SSLEnabled() bool
Click to show internal directories.
Click to hide internal directories.