summaryrefslogtreecommitdiff
path: root/system/api/record.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-02-13 09:18:36 -0800
committerSteve Manuel <nilslice@gmail.com>2017-02-13 09:18:36 -0800
commitf47826071f1e6d7b048d1304d8435a347f9b412a (patch)
tree1990862ba77dfce49325cc39c017a76a97c366c5 /system/api/record.go
parent6ea648ae4306e64f5562ca363e0cdea494ba8d46 (diff)
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
Diffstat (limited to 'system/api/record.go')
-rw-r--r--system/api/record.go16
1 files changed, 16 insertions, 0 deletions
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)
+ })
+}