diff --git a/server/warcserver/api.go b/server/warcserver/api.go index 51f8a2c..a26b9bf 100644 --- a/server/warcserver/api.go +++ b/server/warcserver/api.go @@ -23,6 +23,7 @@ import ( "github.com/julienschmidt/httprouter" "github.com/nlnwa/gowarcserver/schema" + "github.com/nlnwa/gowarcserver/server/api" "github.com/nlnwa/gowarcserver/surt" "github.com/nlnwa/gowarcserver/timestamp" "github.com/nlnwa/whatwg-url/url" @@ -77,7 +78,7 @@ func parseResourceRequest(r *http.Request) (closestRequest, error) { if err != nil { return closestRequest{}, fmt.Errorf("failed to parse uri: %w", err) } - key := surt.UrlToSsurt(u) + key := api.MatchType(surt.UrlToSsurt(u), api.MatchTypeExact) return closestRequest{ rawUrl: uri, diff --git a/server/warcserver/handler.go b/server/warcserver/handler.go index 6d2bc7b..a5bd1fb 100644 --- a/server/warcserver/handler.go +++ b/server/warcserver/handler.go @@ -86,6 +86,11 @@ func (h Handler) resource(w http.ResponseWriter, r *http.Request) { return } + start := time.Now() + defer func() { + log.Debug().Str("request", fmt.Sprintf("%+v", closestReq)).Msgf("Fetched resource in %s", time.Since(start)) + }() + ctx, cancelQuery := context.WithTimeout(r.Context(), 10*time.Second) defer cancelQuery()