java - How are Jersey @Consumes endpoints matched? -


i designing restful endpoint receive files. accept posting both plain file/stream , multipart. there rule how endpoints matched servlet container? code below work reliably, or implementation specific? can away wildcard, or have limit application_octet_stream?

@path("foo") public class foo {     @post     @path("{filename}")     @consumes(mediatype.wildcard)     public response uploadfiledirect(         @pathparam("filename") string filename,         inputstream is)     {         // process input stream         response.ok().build();     }      @post     @path("{filename}")     @consumes(mediatype.multipart_form_data)     public response uploadfilemultipart(         @pathparam("filename") string filename,         @formdataparam("file") inputstream is)     {         // process input stream         response.ok().build();     } } 

this specified in jax-rs spec 3.7.2 request matching

[...]

resource class/object found , resource , sub resource methods put set m

[...]

  1. identify method handle request:
    a. filter m removing members not meet following criteria:
        [...]
    b. sort m in descending order follows:
        * primary key media type of input data. methods @consumes value best match media type of request sorted first.
        * secondary key @produces value. methods value of @produces best matches value of request accept header sorted first.

determining best matching media types follows general rule: n/m > n/* > */*, i.e. method explicitly consumes request media type or produces 1 of requested media types sorted before method consumes or produces */*.

if @ last paragraph (that determines best matching), says */* (mediatype.wildcard) given least priority. more specific media types win.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -