summaryrefslogtreecommitdiff
path: root/system/api/record.go
diff options
context:
space:
mode:
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)
+ })
+}