Can you design the following requirements?
Develop a /healthcheck API with token authentication. Its main responsibilities should be as follows:
- Authenticate the client and return a JWT string
- Authorize client API requests by validating the JWT
You should use the knowledge you gained about the jwt-go package from the previous section. You have to build two endpoints, as follows:
- /getToken
- /healthcheck
The first endpoint should successfully log in a client and return a JWT token. The client should then use the second endpoint with the token to receive a successful response.
Post-development, the final API testing scenario should look something similar to this:
- If you make a GET request to the /healthcheck API without any token, you should receive an Access Denied message, as shown here:
Access Denied; Please check the access token
- You should be able to authenticate...