Skip to content

Commit

Permalink
Merge pull request #75 from nlnwa/fix-resource-request
Browse files Browse the repository at this point in the history
warcserver: Fix resource request
  • Loading branch information
maeb authored Feb 16, 2023
2 parents 4e931c3 + cd7e756 commit 88e475a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/warcserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions server/warcserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 88e475a

Please sign in to comment.