I am new to go language or golang and I am creating an application using Angular-4 as front-end and go as API server. The database I that am using is mongodb.
So, I have created an endpoint APIs using gin in go.
The APIs are working good and I have created a login API which gets the email and password and if email and password is correct, it creates a JWT token and returns the JWT token in response.
The JWT token consists of following things :
- userId.
- User Role.
- Current server time.
If the user's email and password is correct the server create a JWT token and saved it in the user's collection and return it to the client side and saved it to the local storage.
I want to save the token to the server like in PHP or Java applications. Someone advised me to store the JWT token in server local storage or memory instead of saving it to the user's cookie.
I am using gin package not http package. So please help me with the reference of gin package.
I have searched too much for the session but I found the way related to http and I have also read about gorilla's session but what I get is it is for client side and I want to save the token on server side.