server

package
v0.0.0-...-4f2f9b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer() *http.Server

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func (*Server) Login

func (s *Server) Login(c *gin.Context)

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 (s *Server) RegisterRoutes() http.Handler

func (*Server) SignUp

func (s *Server) SignUp(c *gin.Context)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL