1 Star 0 Fork 1

ttpc2008 / BaiduPCS-Go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
middleware.go 802 Bytes
一键复制 编辑 原始数据 按行查看 历史
package pcsweb
import (
"net/http"
)
func middleware(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// next handler
next.ServeHTTP(w, r)
}
}
func activeAuthMiddleware(next http.HandlerFunc) http.HandlerFunc {
next2 := middleware(next)
// TODO web登录
return func(w http.ResponseWriter, r *http.Request) {
next2.ServeHTTP(w, r)
}
}
// rootMiddleware 根目录中间件
func rootMiddleware(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
// 跳转到 /index.html
w.Header().Set("Location", "/index.html")
http.Error(w, "", 301)
} else {
w.Header().Set("X-Content-Type-Options", "nosniff")
w.WriteHeader(404)
tmpl := boxTmplParse("index", "index.html", "404.html")
checkErr(tmpl.Execute(w, nil))
}
}
1
https://gitee.com/ttpc2008/BaiduPCS-Go.git
git@gitee.com:ttpc2008/BaiduPCS-Go.git
ttpc2008
BaiduPCS-Go
BaiduPCS-Go
v3.5.6

搜索帮助