Skip to content

Commit

Permalink
add log
Browse files Browse the repository at this point in the history
  • Loading branch information
Sianao committed Nov 25, 2024
1 parent d30dc4e commit 8f187d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion handler/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/gorilla/mux"
"github.com/sianao/gitproxy/moudule"
"github.com/sianao/gitproxy/router"
"github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -51,14 +52,15 @@ func urlProcess(w http.ResponseWriter, r *http.Request) string {
return ""
}
}
func NewHandler(route *mux.Router) http.HandlerFunc {
func NewHandler(route *mux.Router, log *logrus.Logger) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.RequestURI == "/" || strings.HasPrefix(r.RequestURI, "/_next/") {
router.ServeHTTP(w, r, route)
return
}
var types = urlProcess(w, r)
if types == "" {
log.Errorln(r.RequestURI)
return
}
//去除掉host方便进入路由匹配
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func main() {
l := logrus.New()
router := router.NewRouter(l)
srv := &http.Server{
Handler: handler.NewHandler(router),
Handler: handler.NewHandler(router, l),
Addr: "0.0.0.0:8888",
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
Expand Down

0 comments on commit 8f187d4

Please sign in to comment.