diff options
-rw-r--r-- | system/api/handlers.go | 4 | ||||
-rw-r--r-- | system/api/server.go | 14 |
2 files changed, 7 insertions, 11 deletions
diff --git a/system/api/handlers.go b/system/api/handlers.go index 8a1517b..c238ca9 100644 --- a/system/api/handlers.go +++ b/system/api/handlers.go @@ -200,14 +200,14 @@ func SendJSON(res http.ResponseWriter, j map[string]interface{}) { // CORS wraps a HandleFunc to response to OPTIONS requests properly func CORS(next http.HandlerFunc) http.HandlerFunc { - return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + return db.CacheControl(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { if req.Method == http.MethodOptions { SendPreflight(res) return } next.ServeHTTP(res, req) - }) + })) } // Record wraps a HandleFunc to record API requests for analytical purposes diff --git a/system/api/server.go b/system/api/server.go index 703a906..f8c9ba9 100644 --- a/system/api/server.go +++ b/system/api/server.go @@ -1,18 +1,14 @@ package api -import ( - "net/http" - - "github.com/bosssauce/ponzu/system/db" -) +import "net/http" // Run adds Handlers to default http listener for API func Run() { - http.HandleFunc("/api/types", Record(db.CacheControl(CORS(typesHandler)))) + http.HandleFunc("/api/types", Record((CORS(typesHandler)))) - http.HandleFunc("/api/contents", Record(db.CacheControl(CORS(contentsHandler)))) + http.HandleFunc("/api/contents", Record((CORS(contentsHandler)))) - http.HandleFunc("/api/content", Record(db.CacheControl(CORS(contentHandler)))) + http.HandleFunc("/api/content", Record((CORS(contentHandler)))) - http.HandleFunc("/api/content/external", Record(db.CacheControl(CORS(externalContentHandler)))) + http.HandleFunc("/api/content/external", Record((CORS(externalContentHandler)))) } |