This repository serves as a practical illustration of leveraging Golang's context
package to seamlessly integrate user information into API requests through an authentication middleware. By adopting this approach, you gain the ability to utilize user information for purposes such as tracking, context cancellation, and recovery.
- Clone the repository.
- Execute
go mod tidy
. - Run the application using
go run cmd/main.go
.
To exemplify the utilization of the implemented functionality, execute the following CURL command:
curl -X POST http://localhost:8080/users -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJ1dWlkIjoieHB0byJ9.MQtNhTd7J5uMZ86TdCZY2HXW1CZAnnWcdSnaLfjahKM"