content-negotiation

Laravel 4 RESTful Api with content negotiation

≡放荡痞女 提交于 2019-12-23 04:59:10
问题 I'm working in a RESTFul API with laravel, and I want to use content negotiation in my project, but I don't know how to accomplish that. I have my controllers separted by api version, and I want to distinguish between api versions and use the correct controllerdepending on the version. My API router is: Route::group(array('prefix' => 'api'), function() { Route::resource('users', 'API\V1\UsersController'); }); Should I create a api.type filter to use in my route group or Should I do that in

Serving RDF representation of Java model with Spring MVC?

穿精又带淫゛_ 提交于 2019-12-21 21:26:33
问题 How can I serve an RDF representation of a Java model via Spring MVC? I have JSON and XML representations working using Spring's content negotiation mechanisms and would like to do the same for RDF. 回答1: Assuming that you are using annotation driven configuration for your MVC application, this actually could be quite simple. Using the W3C's Media Types Issues for Text RDF Formats as a guide for content type specification, it's quite easy to augment your existing solution. The real question is

Specify supported media types when sending “415 unsupported media type”

南楼画角 提交于 2019-12-19 05:16:08
问题 If a clients sends data in an unsupported media type to a HTTP server, the server answers with status "415 unsupported media type". But how to tell the client what media types are supported? Is there a standard or at least a recommended way to do so? Or would it just be written to the response body as text? 回答1: There is no specification at all for what to do in this case, so expect implementations to be all over the place. (What would be sensible would be if the server's response included

Specify supported media types when sending “415 unsupported media type”

故事扮演 提交于 2019-12-19 05:16:08
问题 If a clients sends data in an unsupported media type to a HTTP server, the server answers with status "415 unsupported media type". But how to tell the client what media types are supported? Is there a standard or at least a recommended way to do so? Or would it just be written to the response body as text? 回答1: There is no specification at all for what to do in this case, so expect implementations to be all over the place. (What would be sensible would be if the server's response included

Link relation type for linking representations to the abstract resource?

旧街凉风 提交于 2019-12-13 00:31:51
问题 I use Content negotiation to let user-agents select one of several representations for a resource. Example : the resource http://example.com/essay has the following representations: text/html → http://example.com/essay.html application/xhtml+xml → http://example.com/essay.xhtml application/pdf → http://example.com/essay.pdf Let’s say the user-agent selects the HTML variant. Now I could link the other representations with the link relation type alternate: <link rel="alternate" type=

ASP.NET MVC 4 / Web API - insert Razor renderer for Accepts: text/html

房东的猫 提交于 2019-12-12 07:56:04
问题 I am creating a RESTful Web Service using ASP.NET MVC 4 Web API. For API access, I am returning JSON, though once I get everything working correctly, the content negotiation should work for XML and JSON by default. Since I am working towards a truly RESTful resource-centric web service, my URI's will be pointing to actual resources. I would like to take advantage of that by returning an HTML representation of the resource if Accepts: text/html comes in the request (like throwing the link in a

mod_rewrite rules and content negotiation

与世无争的帅哥 提交于 2019-12-11 19:09:02
问题 I am relatively new to mod_rewrite, but have a site which I would like to have "pretty urls." Similarly to SO :). I am attempting to have things like: "http://www.whatever.com/search/test" get rewritten to "http://www.whatever.com/search.php?q=test" and have had some limited success. I believe that content negotiation is getting in my way... For starters here's my test .htaccess file: RewriteEngine on RewriteBase /~user/mysite/ RewriteRule ^search$ search/ [R] RewriteRule ^search/([^/]*)/?$

issues with xml in spring mvc 3

巧了我就是萌 提交于 2019-12-11 09:19:41
问题 See my following 4 simple examples, 2 works for xml, the other 2 does not. //works for html, json, xml @RequestMapping(value = "/test", method = RequestMethod.GET) public ModelAndView testContentNegiotation(HttpServletRequest request, HttpServletResponse response) { ModelAndView mav = new ModelAndView(); TestTO test = new TestTO("some msg", -888); mav.addObject("test", test); mav.setViewName("test"); //test is a jsp page return mav; } //does not work for xml @RequestMapping(value = "/test",

Accept Language list

时光怂恿深爱的人放手 提交于 2019-12-09 08:35:30
问题 I would like to react to the Accept_Language that a browser sends to a website. Does anybody know where I can get a reliable list of all available Accept_Languages that the browser might send to a website? Thank you very much! 回答1: IANA Language Subtag Registry page This is the official location where you will find all subtags available for use in language tags. W3 said it's the authoritative list . Plus, at the link below, there is a lot more information to be had, including descriptions and

Linked Data (RDF) Content Negotiation with apache

孤者浪人 提交于 2019-12-08 07:48:52
问题 I was wondering if someone could provide me with the typical rule, to serve the appropriate file when a resource is requested, with respect to the content type required. To be more specific here is my situation: I have a purl URL that i redirect to an URL on my apache server. I would like to resource URL to be like a generic URL for the resource, and then serve the appropriate doc depending on the content Type: RDF, TTL, or HTML. Hence i would like to know how to do that within the .htaccess