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.

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top