mirror of
https://github.com/labstack/echo.git
synced 2024-11-28 08:38:39 +02:00
parent
533792b86c
commit
15ce60e346
@ -59,7 +59,7 @@ func TestContext(t *testing.T) {
|
||||
//------
|
||||
|
||||
// JSON
|
||||
testBind(t, c, ApplicationJSON)
|
||||
testBind(t, c, "application/json")
|
||||
|
||||
// XML
|
||||
c.request, _ = http.NewRequest(POST, "/", strings.NewReader(userXML))
|
||||
|
4
echo.go
4
echo.go
@ -180,9 +180,9 @@ func New() (e *Echo) {
|
||||
e.SetBinder(func(r *http.Request, v interface{}) error {
|
||||
ct := r.Header.Get(ContentType)
|
||||
err := UnsupportedMediaType
|
||||
if strings.HasPrefix(ct, ApplicationJSON) {
|
||||
if strings.HasPrefix(ApplicationJSON, ct) {
|
||||
err = json.NewDecoder(r.Body).Decode(v)
|
||||
} else if strings.HasPrefix(ct, ApplicationXML) {
|
||||
} else if strings.HasPrefix(ApplicationXML, ct) {
|
||||
err = xml.NewDecoder(r.Body).Decode(v)
|
||||
}
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user