ostinelli / misultin

Misultin (pronounced mee-sool-téen) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle to multiple content_types in one url?

leiwan5 opened this issue · comments

as respond_to in rails does?

Send headers like this. For HTML:

Req:ok([{"Content-Type", "text/html"}], "<b>hello</b>").

For Text:

Req:ok([{"Content-Type", "text/plain"}], "hello").

This is well documented, please read the documentation and the examples, I can scarcely see this as an 'issue'. :)

r.

Sorry, I didn't describe it clearly.
For example, $.get('/users', function(){}) is expected to get an html page with users list, and $.get('/users', function(){}, 'json') a json string.
I know how to response different content-types. I want to know if there is an easy way to know what content-type the client want, or I can only parse the request header myself? or use different urls in the client, like '/users.html' and '/users.json'?