1

Can we create custom http request in spring boot? We have already GET, POST, PUT etc.

Can we create "customHttp" request method and use them insted of those are already we have in spring boot. Is this possible in java or in spring boot?

@RequestMapping(value="/",method = RequestMethod.customHttp)
3
  • 2
    It's possible, but don't. Stick to the standard HTTP verbs. Everything that calls your service will have problems if you do this. Commented Dec 6, 2022 at 15:14
  • Thanks for your reply... I have XMLHttpRequest.open("someService", uri, true) I am trying to call by rest temple in spring. Whenever I call this I am getting 405 method not allowed [no body] error. Commented Dec 6, 2022 at 15:21
  • 2
    That doesn't sound like you need custom HTTP verbs. Perhaps you should ask a question about your actual problem. Commented Dec 6, 2022 at 15:24

1 Answer 1

1

The RequestMethod covers nearly all request types, that are defined in RFC 9110, except CONNECT which can be handled with other methods. If you want to create your own request type, you can try to go into @RequestMapping annotation to see how it works.

Edited: I do not recommend to do this, because of world RFC 9110 that was created especially for strict specs of HTTP/1.1

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your reply... I have XMLHttpRequest.open("someService", uri, true) I am trying to call by rest temple in spring. Whenever I call this I am getting 405 method not allowed [no body] error.
Unfotunately, there is no such skill as "Second Side" in my superhero skill list)) Can you please share the code that is responsible for this endpoint coverage (i mean, from front- and backend at the same time)
What's more, XMLHttpRequest.open() has strict syntax developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open BTW, my recommendation is to use at least ajax lib for frontend (best, imho is axios)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.