Rapidoid request Content-type

392 Views Asked by At

I'm building an API in rapidoid and have received an additional requirement to accept application/vnd.api+json rather than application/json.

Although rapidoid will accept the request and processes it correctly, it's logging an error (shown below). Is there a way to stop rapidoid from raising this error or specify a list of content types that should be permitted?

java.lang.RuntimeException: Couldn't parse the request body - unsupported content type: application/vnd.api+json
    at org.rapidoid.u.U.rte(U.java:423)
    at org.rapidoid.http.impl.ReqImpl.parseRequestBody(ReqImpl.java:812)
    at org.rapidoid.http.impl.ReqImpl.posted(ReqImpl.java:244)
    at org.rapidoid.http.impl.ReqImpl.posted(ReqImpl.java:330)
    at org.rapidoid.http.impl.ReqImpl.data(ReqImpl.java:379)
    at org.rapidoid.http.HttpUtils.initAndDeserializeToken(HttpUtils.java:81)
    at org.rapidoid.http.impl.ReqImpl.token(ReqImpl.java:694)
    at org.rapidoid.http.impl.ReqImpl.hasToken(ReqImpl.java:682)
    at org.rapidoid.http.HttpUtils.getAuth(HttpUtils.java:306)
    at org.rapidoid.http.handler.HttpAuthWrapper.wrap(HttpAuthWrapper.java:52)
    at org.rapidoid.http.handler.HttpManagedHandlerDecorator.wrap(HttpManagedHandlerDecorator.java:185)
    at org.rapidoid.http.handler.HttpManagedHandlerDecorator.handleWithWrappers(HttpManagedHandlerDecorator.java:100)
    at org.rapidoid.http.handler.HttpManagedHandlerDecorator.access$200(HttpManagedHandlerDecorator.java:39)
    at org.rapidoid.http.handler.HttpManagedHandlerDecorator$2.run(HttpManagedHandlerDecorator.java:83)
    at org.rapidoid.job.PredefinedContextJobWrapper.run(PredefinedContextJobWrapper.java:56)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
1

There are 1 best solutions below

0
taha On

you should use ReqRespHandler, for example:

On.get("/test").html((req, resp)-> "this is a test!");