Handle OPTIONS for CORS preflight.

pull/1565/head
Todd Persen 2015-02-10 23:03:38 -08:00
parent 4cdda0ba31
commit 4e17f4dbc0
1 changed files with 9 additions and 0 deletions

View File

@ -58,6 +58,10 @@ func NewHandler(s *influxdb.Server, requireAuthentication bool, version string)
"query", // Query serving route.
"GET", "/query", h.serveQuery, true,
},
route{
"write", // Data-ingest route.
"OPTIONS", "/write", h.serveOptions, true,
},
route{
"write", // Data-ingest route.
"POST", "/write", h.serveWrite, true,
@ -223,6 +227,11 @@ func (h *Handler) serveStatus(w http.ResponseWriter, r *http.Request) {
w.Write(b)
}
// serveOptions returns an empty response to comply with OPTIONS pre-flight requests
func (h *Handler) serveOptions(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent)
}
// servePing returns a simple response to let the client know the server is running.
func (h *Handler) servePing(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent)