Closed imihajlow closed 6 years ago
Nice, let's add a test for this, as well.
@fadushin merge pls?
@imihajlow I'd like to change the return semantics of the API handler, so that by default the handler will return an object that can be translated to JSON, unless the return type is a tuple, in which case the first element of the tuple contains the content type (as a string), and the second contains the data.
This makes the interface cleaner for the target use-case (JSON API), but allows implementors to define their own return types. I find it makes it easier to handle all JSON types (dicts, lists, ints, floats, bools, and strings), whereas when a handler returns string, it always is interpreted as HTML.
It does mean you will need to change your code to adapt to this semantic change.
Hi @fadushin, Thanks for notifying, but I don't use micropython in my project anymore due to an unavoidable mbedtls/lwip bug. However, this sounds like a good change.
REST is good, but generating HTML pages on-the-fly is also good and useful. Returning a string from the get/post/put/delete methods sends an HTML content-type.