Documentation
¶
Index ¶
- Constants
- func SwitchDebug(w http.ResponseWriter, r *http.Request)
- type ErrPageFunc
- type LoginInfo
- type Router
- func (ro *Router) BeforeAction(w http.ResponseWriter, r *http.Request) bool
- func (ro *Router) Captcha(w http.ResponseWriter, r *http.Request)deprecated
- func (ro *Router) DelCookie(w http.ResponseWriter, k, path string)deprecated
- func (ro *Router) GetSession() *session.Manager
- func (ro *Router) Index(w http.ResponseWriter, r *http.Request)
- func (ro *Router) Middleware(w http.ResponseWriter, r *http.Request, ...)
- func (ro *Router) Play(w http.ResponseWriter, r *http.Request, fname string, args ...any)deprecated
- func (ro *Router) SetCookie(w http.ResponseWriter, k, value, path string)deprecated
- func (ro *Router) SetDev(dev bool)
- func (ro *Router) SetSession(sessionManager *session.Manager)
- func (ro *Router) SetStaticEmbedFs(p string, embedFS *embed.FS, prefix ...string)
Constants ¶
View Source
const CaptchaID = "captcha"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrPageFunc ¶
type ErrPageFunc func(w http.ResponseWriter, resp *route.ErrorResp)
type LoginInfo ¶
type Router ¶
type Router struct {
Default string `ini:"default" json:"default" yaml:"default"`
Root string `ini:"root" json:"root" yaml:"root"`
HttpCache bool `ini:"http_cache" json:"http_cache" yaml:"http_cache"`
HttpCacheMaxAge string `ini:"http_cache_max_age" json:"http_cache_max_age" yaml:"http_cache_max_age"`
SessionLoginName string `ini:"session_login_name" json:"session_login_name" yaml:"session_login_name"` // 系统中,用于在session中存储登录信息的key
// cookie相关配置
CookiePath string `ini:"cookie_path" json:"cookie_path" yaml:"cookie_path"`
CookieDomain string `ini:"cookie_domain" json:"cookie_domain" yaml:"cookie_domain"`
CookieSecure bool `ini:"cookie_secure" json:"cookie_secure" yaml:"cookie_secure"`
CookieHttpOnly bool `ini:"cookie_http_only" json:"cookie_http_only" yaml:"cookie_http_only"`
Error ErrPageFunc // 错误页面处理函数
ErrorWithLog ErrPageFunc // 错误页面处理函数
IsLogin bool // 是否登录
LoginPath string // 登录页面
HomePage string //首页
UnLoginPath map[string]bool // 免授权页面
UnLoginPathRegexp []*regexp.Regexp // 免授权页面正则
MustLoginPath map[string]bool //必须登录才能访问的页面
MustLoginPathRegexp []*regexp.Regexp // 必须登录才能访问的页面正则
DisableLoginPath map[string]bool // 登录状态下不能访问的页面
DisableLoginPathRegexp []*regexp.Regexp // 登录状态下不能访问的页面正则
ManagePage map[string]bool // 管理员访问
ManagePageRegexp []*regexp.Regexp
// contains filtered or unexported fields
}
func (*Router) BeforeAction ¶
BeforeAction 所有应用前置操作 Deprecated: 请使用 http server 中间件模式
func (*Router) DelCookie
deprecated
func (ro *Router) DelCookie(w http.ResponseWriter, k, path string)
Deprecated: 请使用 github.com/helays/utils/v2/net/http/cookiekit.DelCookie
func (*Router) GetSession ¶
func (*Router) Index ¶
func (ro *Router) Index(w http.ResponseWriter, r *http.Request)
if ro.HttpCache {
w.Header().Set("cache-control", "max-age="+ro.HttpCacheMaxAge)
if len(files) == 1 {
fileInfo, _ := files[0].Stat()
w.Header().Set("last-modified", fileInfo.ModTime().Format(time.RFC822))
}
}
上面的后续待定 Deprecated: 请使用route.Index
func (*Router) Middleware ¶
func (ro *Router) Middleware(w http.ResponseWriter, r *http.Request, f func(w http.ResponseWriter, r *http.Request, ro *Router))
Middleware 中间件 Deprecated: 请使用 http server 中间件模式
func (*Router) SetCookie
deprecated
func (ro *Router) SetCookie(w http.ResponseWriter, k, value, path string)
Deprecated: 请使用 github.com/helays/utils/v2/net/http/cookiekit.SetCookie
func (*Router) SetSession ¶
Click to show internal directories.
Click to hide internal directories.