Search code examples
spring-bootspring-mvcspring-cloud-function

How to map path elements to method parameter in spring cloud function web


I'm working on a Microservice that receives webhooks, the idea is to use path variables for some processing down stream,

/webhooks/{foo}/{bar}/{baz}

for example

/webhooks/sony/pony/tony would populate foo=sony; bar=pony; baz=tony.

Can't figure how to make it work in spring cloud function web.


Solution

  • This was never the purpose of spring-cloud-function to replace spring-mvc etc. Also, Function has only one argument, so what you can do is have Function<Message, ...> and we translate HTTP request into Message where body will turn into payload and HTTP headers will turn into Message headers.