Skip to content

Missing content type header in serializable type handler  #132

@okoumea

Description

@okoumea

hi,

I return a model object from a route, the object has a "toJson()" function, as expected by the fallback serializable type handler, the function is called and the response is sent, however my client side parser fails because it receives the response as a string, while it was expected a json.

i think that the serializable handler should sent a ContentType.json content type header like the json type handler :

        if (value.toJson != null) {
          **res.headers.contentType = ContentType.json;**
          res.write(jsonEncode(value.toJson()));
          return res.close();
        }

...

        if (value.toJSON != null) {
          **res.headers.contentType = ContentType.json;**
          res.write(jsonEncode(value.toJson()));
          return res.close();
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions