Question

Building a basic api that accepts posts on an endpoint to add data and display on a dashboard. I would like the api to require a token for posts to be permitted but I am not sure how to do so... I am using the sugar framework to handle http requests.

Était-ce utile?

La solution

You could use route guards I suppose:

post "/resource/:api_key" when api_key == @api_key, Controller, :dostuff

Sugar is still really alpha, so I don't know if it supports middleware yet or not. You might be better off using Plug directly until Sugar stabilizes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top