문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top