Handle OPTIONS for CORS preflight.
parent
4cdda0ba31
commit
4e17f4dbc0
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue