1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-28 08:38:39 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-07-16 08:05:16 -07:00
parent 533792b86c
commit 15ce60e346
2 changed files with 3 additions and 3 deletions

View File

@ -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))

View File

@ -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