feat: 增加自定义中间件功能,增加设置http的几个超时设定

This commit is contained in:
dexter
2022-12-19 13:48:38 +08:00
parent 1e1a86cd4b
commit 75b150a3cc
5 changed files with 81 additions and 17 deletions

View File

@@ -62,7 +62,7 @@ func ListenUDP(address string, networkBuffer int) (*net.UDPConn, error) {
}
// CORS 加入跨域策略头包含CORP
func CORS(next http.HandlerFunc) http.HandlerFunc {
func CORS(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
header := w.Header()
header.Set("Access-Control-Allow-Credentials", "true")
@@ -80,7 +80,7 @@ func CORS(next http.HandlerFunc) http.HandlerFunc {
})
}
func BasicAuth(u, p string, next http.HandlerFunc) http.HandlerFunc {
func BasicAuth(u, p string, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Extract the username and password from the request
// Authorization header. If no Authentication header is present