Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Login ¶
Login handles the /login route.
It takes a JSON payload with an email and password. If the email and password are valid, it returns a 200 status code with a JSON response containing a success message and sets a cookie with a JWT token. If the email or password is invalid, it returns a 401 status code with a JSON response containing an error message.
func (*Server) RegisterRoutes ¶
func (*Server) SignUp ¶
SignUp handles the /signup route.
It expects a JSON payload containing the fields: - username: string - name: string - email: string - password: string - confirm_password: string
It validates the input fields, hashes the password and creates a new user in the database. If any of the input fields are invalid, it will return a 400 error with the specific error message. If the passwords do not match, it will return a 400 error with the message "passwords do not match".
If the user is created successfully, it will return a 201 status code with the newly created user as JSON.