Skip to content

Commit

Permalink
Merge pull request #19 from krakend/global_layer_skip_paths
Browse files Browse the repository at this point in the history
Global layer skip paths
  • Loading branch information
kpacha authored Apr 25, 2024
2 parents fcdfcc0 + bfd49a2 commit 20e4cf8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions example/client/make_skip_paths_requests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

for i in {1..1000}
do
# curl localhost:54444/fake/fsf
# curl localhost:54444/combination/2
echo -e "\n/__stats/"
curl localhost:54444/__stats/
echo -e "\n/__health"
curl localhost:54444/__health
echo -e "\n/__echo/"
curl localhost:54444/__echo/
# uncomment this to see real 404 not found error codes
# echo -e "\n/this_does_not_exist/"
# curl localhost:54444/this_does_not_exist/
echo -e "\n----\n"
sleep 1
done
7 changes: 7 additions & 0 deletions http/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ type trackingHandler struct {
metrics *metricsHTTP
traces *tracesHTTP
reportHeaders bool
config state.Config
}

func (h *trackingHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
if r.URL != nil && h.config.SkipEndpoint(r.URL.Path) {
h.next.ServeHTTP(rw, r)
return
}

t := newTracking()
t.ctx = r.Context()
if h.prop != nil {
Expand Down Expand Up @@ -84,5 +90,6 @@ func NewTrackingHandler(next http.Handler) http.Handler {
metrics: m,
traces: t,
reportHeaders: gCfg.ReportHeaders,
config: otelCfg,
}
}

0 comments on commit 20e4cf8

Please sign in to comment.