We recently added a token-based authentication example to the Siesta repository that provides an excellent starting point for building authenticated APIs using our lightweight HTTP handler library for Go. This example, modeled after our own internal API services, demonstrates features and practices that we’ve developed and found useful after using Siesta in production for many months.
Here’s what you’ll see in this “meaty” example:
- Request identification and logging
- Token-based authentication
- Use of typed URL parameters
- Usage of a handler for some state, such as a database
- JSON responses
- “Pre” and “post” middleware chains
- Error handling and bypassing of handlers …