go-proxy-bingai/api/index.go

24 lines
485 B
Go
Raw Normal View History

2023-05-04 11:29:40 +08:00
package api
import (
"adams549659584/go-proxy-bingai/api/helper"
2023-05-04 11:29:40 +08:00
"adams549659584/go-proxy-bingai/common"
"net/http"
2023-05-26 15:12:41 +08:00
"strings"
2023-05-04 11:29:40 +08:00
)
func Index(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
2023-05-08 12:07:55 +08:00
http.Redirect(w, r, common.PROXY_WEB_PAGE_PATH, http.StatusFound)
2023-05-26 15:12:41 +08:00
return
}
2023-06-01 23:23:55 +08:00
if strings.HasPrefix(r.URL.Path, "/turing") {
if !helper.CheckAuth(r) {
helper.UnauthorizedResult(w)
return
}
2023-05-04 11:29:40 +08:00
}
2023-05-26 15:12:41 +08:00
common.NewSingleHostReverseProxy(common.BING_URL).ServeHTTP(w, r)
2023-05-04 11:29:40 +08:00
}