diff --git a/gen_router.go b/gen_router.go index 50f0d141..b3ad7519 100644 --- a/gen_router.go +++ b/gen_router.go @@ -803,12 +803,13 @@ func init() { co.SetReverseOSMapEnum(reverseOSMapEnum) c.Chrome = agentMapEnum["chrome"] c.Firefox = agentMapEnum["firefox"] + ame := agentMapEnum c.SimpleBots = []int{ - agentMapEnum["semrush"], - agentMapEnum["ahrefs"], - agentMapEnum["python"], - agentMapEnum["go"], - agentMapEnum["curl"], + ame["semrush"], + ame["ahrefs"], + ame["python"], + ame["go"], + ame["curl"], } } @@ -1013,17 +1014,11 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { req.URL.Path = c.Config.DefaultPath } //log.Print("URL.Path: ", req.URL.Path) - - var prefix, extraData string - prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1] - if req.URL.Path[len(req.URL.Path) - 1] != '/' { - extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] - req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] - } + prefix := req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1] // TODO: Use the same hook table as downstream hTbl := c.GetHookTable() - skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix, extraData) + skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix) if skip || ferr != nil { return } @@ -1052,7 +1047,6 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { if !c.Config.DisableAnalytics { co.RouteViewCounter.Bump(167) } - req.URL.Path += extraData routes.StaticFile(w, req) return } @@ -1064,6 +1058,12 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { r.requestLogger.Print("before PreRoute") } + var extraData string + if req.URL.Path[len(req.URL.Path) - 1] != '/' { + extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] + req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] + } + /*if c.Dev.QuicPort != 0 { w.Header().Set("Alt-Svc", "quic=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=2592000; v=\"44,43,39\", h3-23=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h3-24=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h2=\":443\"; ma=3600") }*/ diff --git a/router_gen/main.go b/router_gen/main.go index 96c0e297..a3b3a3bb 100644 --- a/router_gen/main.go +++ b/router_gen/main.go @@ -481,12 +481,13 @@ func init() { co.SetReverseOSMapEnum(reverseOSMapEnum) c.Chrome = agentMapEnum["chrome"] c.Firefox = agentMapEnum["firefox"] + ame := agentMapEnum c.SimpleBots = []int{ - agentMapEnum["semrush"], - agentMapEnum["ahrefs"], - agentMapEnum["python"], - agentMapEnum["go"], - agentMapEnum["curl"], + ame["semrush"], + ame["ahrefs"], + ame["python"], + ame["go"], + ame["curl"], } } @@ -691,17 +692,11 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { req.URL.Path = c.Config.DefaultPath } //log.Print("URL.Path: ", req.URL.Path) - - var prefix, extraData string - prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1] - if req.URL.Path[len(req.URL.Path) - 1] != '/' { - extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] - req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] - } + prefix := req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1] // TODO: Use the same hook table as downstream hTbl := c.GetHookTable() - skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix, extraData) + skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix) if skip || ferr != nil { return } @@ -730,7 +725,6 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { if !c.Config.DisableAnalytics { co.RouteViewCounter.Bump({{index .AllRouteMap "routes.StaticFile"}}) } - req.URL.Path += extraData routes.StaticFile(w, req) return } @@ -742,6 +736,12 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { r.requestLogger.Print("before PreRoute") } + var extraData string + if req.URL.Path[len(req.URL.Path) - 1] != '/' { + extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] + req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] + } + /*if c.Dev.QuicPort != 0 { w.Header().Set("Alt-Svc", "quic=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=2592000; v=\"44,43,39\", h3-23=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h3-24=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h2=\":443\"; ma=3600") }*/