From f47826071f1e6d7b048d1304d8435a347f9b412a Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 13 Feb 2017 09:18:36 -0800 Subject: adding item.Omittable interface for field-level omission of data in responses, implementation in handler and separating source into individual files for other interface impls --- system/api/record.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 system/api/record.go (limited to 'system/api/record.go') diff --git a/system/api/record.go b/system/api/record.go new file mode 100644 index 0000000..93d4aaf --- /dev/null +++ b/system/api/record.go @@ -0,0 +1,16 @@ +package api + +import ( + "net/http" + + "github.com/ponzu-cms/ponzu/system/api/analytics" +) + +// Record wraps a HandlerFunc to record API requests for analytical purposes +func Record(next http.HandlerFunc) http.HandlerFunc { + return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + go analytics.Record(req) + + next.ServeHTTP(res, req) + }) +} -- cgit v1.2.3