{"action":"created","issue":{"url":"https://api.github.com/repos/tomkuijsten/restup/issues/65","repository_url":"https://api.github.com/repos/tomkuijsten/restup","labels_url":"https://api.github.com/repos/tomkuijsten/restup/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/tomkuijsten/restup/issues/65/comments","events_url":"https://api.github.com/repos/tomkuijsten/restup/issues/65/events","html_url":"https://github.com/tomkuijsten/restup/issues/65","id":161033467,"number":65,"title":"Allow adding header values from the controller","user":{"login":"stevegg","id":11695895,"avatar_url":"https://avatars.githubusercontent.com/u/11695895?v=3","gravatar_id":"","url":"https://api.github.com/users/stevegg","html_url":"https://github.com/stevegg","followers_url":"https://api.github.com/users/stevegg/followers","following_url":"https://api.github.com/users/stevegg/following{/other_user}","gists_url":"https://api.github.com/users/stevegg/gists{/gist_id}","starred_url":"https://api.github.com/users/stevegg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevegg/subscriptions","organizations_url":"https://api.github.com/users/stevegg/orgs","repos_url":"https://api.github.com/users/stevegg/repos","events_url":"https://api.github.com/users/stevegg/events{/privacy}","received_events_url":"https://api.github.com/users/stevegg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-06-18T16:59:26Z","updated_at":"2016-06-21T09:02:31Z","closed_at":null,"body":"I have  a use case where I want to use a REST api to return an image. Right now there's no way (that I could find) to modify the content-type header before it's returned to the caller.  What would be great is something like:\r\n\r\n```\r\nreturn(GetResponse)new GetResponse(GetResponse.ResponseStatus.OK, result)\r\n                       .addHeader(\"Content-Type\", \"image/jpeg\");\r\n```\r\n\r\nIt would also be useful to have some way to add headers to all responses (event?).  This would allow adding things like CORS headers.  e.g. : \r\n\r\n```\r\n.addHeader(\"Access-Control-Allow-Origin\", \"*\")\r\n.addHeader(\"Access-Control-Allow-Headers\", \"x-requested-with \");\r\n```"},"comment":{"url":"https://api.github.com/repos/tomkuijsten/restup/issues/comments/227382026","html_url":"https://github.com/tomkuijsten/restup/issues/65#issuecomment-227382026","issue_url":"https://api.github.com/repos/tomkuijsten/restup/issues/65","id":227382026,"user":{"login":"Jark","id":754147,"avatar_url":"https://avatars.githubusercontent.com/u/754147?v=3","gravatar_id":"","url":"https://api.github.com/users/Jark","html_url":"https://github.com/Jark","followers_url":"https://api.github.com/users/Jark/followers","following_url":"https://api.github.com/users/Jark/following{/other_user}","gists_url":"https://api.github.com/users/Jark/gists{/gist_id}","starred_url":"https://api.github.com/users/Jark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jark/subscriptions","organizations_url":"https://api.github.com/users/Jark/orgs","repos_url":"https://api.github.com/users/Jark/repos","events_url":"https://api.github.com/users/Jark/events{/privacy}","received_events_url":"https://api.github.com/users/Jark/received_events","type":"User","site_admin":false},"created_at":"2016-06-21T09:02:31Z","updated_at":"2016-06-21T09:02:31Z","body":"Can you point me to any rest document which recommends your approach?\r\n\r\nThis is the pattern I would suggest using:\r\n\r\n```\r\nPUT /api/camera -> returns location /snapshots/<guid/id/name>\r\n```\r\nand then you would have a IHttpHandler listening on /snapshots, all incoming requests would come in with the url `/<guid/id/name>` which you would then map directly to a db query / cache. \r\n\r\nSimilarly your `GET /api/camera/{id}/snapshot` request would return the image url for your page to load. The ImageHttpHandler would be very sample and all the main logic would be in your rest api.\r\n\r\n\r\nAs I've said before I do agree with being able to specify headers to the responses, I've added a pull request with a possible solution that doesn't make the I<method>Responses concrete implementations mutable (and added a test). I do need to add tests for the constructors of the different responses. (#71) Also, I'm wondering if a request factory would be a better solution then having so many overloads of the same constructor (or use optional constructor arguments?).\r\n\r\nHowever to satisfy your use case you would need a second feature, to be able to specify that you don't want your content serialised, or that you possibly want a specify type of serialisation. I will raise an issue for it and then we can see if we will want to do this. @tomkuijsten what do you think about the above?\r\n"}}
{"actor":{"display_login":"Jark"}}