From 26fdb23f3734817f6ae413d00336d2eb57c22735 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Sat, 16 Apr 2016 20:18:20 +0200 Subject: [PATCH] Update user agent regexp --- api/api.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index 70f252e..a354b62 100644 --- a/api/api.go +++ b/api/api.go @@ -20,7 +20,9 @@ import ( const APPLICATION_JSON = "application/json" -var cliUserAgentExp = regexp.MustCompile(`^((curl|Wget|fetch\slibfetch|Go-http-client|HTTPie)\/.*|Go\s1\.1\spackage\shttp)$`) +var USER_AGENT_RE = regexp.MustCompile( + `^(?:curl|Wget|fetch\slibfetch|Go-http-client|HTTPie)\/.*|Go\s1\.1\spackage\shttp$`, +) type API struct { CORS bool @@ -230,7 +232,7 @@ func (a *API) NotFoundHandler(w http.ResponseWriter, r *http.Request) *appError } func cliMatcher(r *http.Request, rm *mux.RouteMatch) bool { - return cliUserAgentExp.MatchString(r.UserAgent()) + return USER_AGENT_RE.MatchString(r.UserAgent()) } func (a *API) requestFilter(next http.Handler) http.Handler {