1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-02-15 14:03:17 +02:00

Fix default responder's content-type check

- Fix #189
This commit is contained in:
Aaron L 2018-09-27 22:06:56 -07:00
parent dc5a3def97
commit d84ea6fac5
2 changed files with 4 additions and 1 deletions

View File

@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Fix a bug where content-types like 'application/json;charset=utf-8' would
not trigger api responses in the default responder.
- Fix LoadCurrentUser error handling, it was swallowing errors when users were
not logged in, changed to be consistent, now returns ErrUserNotFound just like
CurrentUser.

View File

@ -2,6 +2,7 @@ package defaults
import (
"net/http"
"strings"
"github.com/volatiletech/authboss"
)
@ -41,7 +42,7 @@ func (r *Responder) Respond(w http.ResponseWriter, req *http.Request, code int,
}
func isAPIRequest(r *http.Request) bool {
return r.Header.Get("Content-Type") == "application/json"
return strings.HasPrefix(r.Header.Get("Content-Type"), "application/json")
}
// Redirector for http requests