Skip to content

Conversation

thib3113
Copy link
Contributor

@thib3113 thib3113 commented Sep 28, 2023

This PR allow to call a endpoint to generate the rest url .

allow to do :

const svc = {
 name: "users",
 settings: {
  rest: '/users'
 },
 actions: {
  action: {
    rest: 'GET /:id'
  }
 }
}

await ctx.call('gateway.getRest', {action: 'my.action', params: {id:123}}); // => return /users/123

It can be usefull if you want to setup hypermedias, or just generate a link


I'm not sure about the naming, so I reuse the naming from path-to-regexp "compile" .

Not sure about the error throw if missing parameters, but it seems that path-regexp throw an error if a parameter is missing (I also tried with parameter validate to false) .


State of the PR :

  • write tests
  • write documentation

@icebob
Copy link
Member

icebob commented Oct 1, 2023

Good idea, please add relevant tests as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants