Add Tus-Method-Override header

This commit is contained in:
Acconut 2015-07-31 12:35:21 +02:00
parent 75506bc129
commit a284e89e28
1 changed files with 7 additions and 0 deletions

View File

@ -121,6 +121,13 @@ func NewHandler(config Config) (*Handler, error) {
// Implement the http.Handler interface.
func (handler *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Allow overriding the HTTP method. The reason for this is
// that some libraries/environments to not support PATCH and
// DELETE requests, e.g. Flash in a browser and parts of Java
if newMethod := r.Header.Get("Tus-Method-Override"); newMethod != "" {
r.Method = newMethod
}
go logger.Println(r.Method, r.URL.Path)
header := w.Header()