Hi,

I try to see if there is a workaround to avoid this issue (HTTP method not
allowed - 405) or If I have to dig into the code to provide a fix

1) HTTP Method 405 - returned

This REST DSL definition generates a HTTP 405 Method not allowed when this
request is issued (http -v OPTIONS http://localhost:9191/blog/article/)


rest("/blog/").id("rest-blog-service").produces("application/json").consumes("application/json")

 
.get("/article/search/user/{user}").id("rest-searchbyuser").outTypeList(Blog.class)
               .to("direct:searchByUser")

           .put("/article/").id("rest-put-article").type(Blog.class)
               .to("direct:add")

           rest("/blog/article/").id("rest-options")
             .verb("options")
             .route()
             .setHeader("Access-Control-Allow-Origin", constant("*"))
             .setHeader("Access-Control-Allow-Methods", constant("GET,
HEAD, POST, PUT, DELETE, OPTIONS"))
             .setHeader("Access-Control-Allow-Headers", constant("Origin,
Accept, X-Requested-With, Content-Type, Access-Control-Request-Method,
Access-Control-Request-Headers"))
             .setHeader("Allow", constant("GET, HEAD, POST, PUT, DELETE,
OPTIONS"));


http -v options http://localhost:9191/blog/article/
OPTIONS /blog/article/ HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: localhost:9191
User-Agent: HTTPie/0.9.2

-->

HTTP/1.1 405 Method Not Allowed

endpoints registered

 INFO  Route: rest-searchbyid started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article/search/id/%7Bid%7D?httpMethodRestrict=GET]
INFO  Route: rest-searchbyuser started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article/search/user/%7Buser%7D?httpMethodRestrict=GET
]
INFO  Route: rest-put-article started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article?httpMethodRestrict=PUT]
INFO  Route: rest-deletearticle started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article/%7Bid%7D?httpMethodRestrict=DELETE]
INFO  Route: route1 started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article?httpMethodRestrict=OPTIONS]


while this is not the case If I comment the line with the put as you can
see hereafter


2) HTTP Method - 200 OK


rest("/blog/").id("rest-blog-service").produces("application/json").consumes("application/json")


 
.get("/article/search/user/{user}").id("rest-searchbyuser").outTypeList(Blog.class)
               .to("direct:searchByUser")

           /* .put("/article/").id("rest-put-article").type(Blog.class)
               .to("direct:add") */

           rest("/blog/article/").id("rest-options")
             .verb("options")
             .route()
             .setHeader("Access-Control-Allow-Origin", constant("*"))
             .setHeader("Access-Control-Allow-Methods", constant("GET,
HEAD, POST, PUT, DELETE, OPTIONS"))
             .setHeader("Access-Control-Allow-Headers", constant("Origin,
Accept, X-Requested-With, Content-Type, Access-Control-Request-Method,
Access-Control-Request-Headers"))
             .setHeader("Allow", constant("GET, HEAD, POST, PUT, DELETE,
OPTIONS"));


Endpoints

INFO  Route: rest-searchbyid started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article/search/id/%7Bid%7D?httpMethodRestrict=GET]
INFO  Route: rest-searchbyuser started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article/search/user/%7Buser%7D?httpMethodRestrict=GET
]
INFO  Route: rest-deletearticle started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article/%7Bid%7D?httpMethodRestrict=DELETE]
INFO  Route: route1 started and consuming from: Endpoint[
http://0.0.0.0:9191/blog/article?httpMethodRestrict=OPTIONS]



http -v OPTIONS http://localhost:9191/blog/article/

-->

HTTP/1.1 200 OK
Accept: */*
Accept-Encoding: gzip, deflate
Access-Control-Allow-Headers: Origin, Accept, X-Requested-With,
Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS,
CONNECT, PATCH
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3600
Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS


Regards,

-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Reply via email to