Sinatra - API - Authentication
问题 We going to develop a little API application in Sinatra. What are the authentication options available to secure the API calls? 回答1: Sinatra has no built-in authentication support. There are some gems available, but most are designed for user authentication (i.e. for a website). For an API, they seem like overkill. It’s easy enough to make your own. Simply check the request params in each of your routes to see if they contain a valid API key, and if not, return a 401 error. helpers do def