Skip to content

M4rcxs/Golang-CRUD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang CRUD

The middleware package is responsible for handling requests and responses between a server and a PostgreSQL database.

Routes

Route HTTP Method Description
/users GET Returns all users from the database.
/user/{id} GET Returns a user with the specified ID from the database.
/newuser POST Creates a new user in the database.
/user/{id} PUT Updates a user with the specified ID in the database.
/deleteuser/{id} DELETE Deletes a user with the specified ID from the database.

Functions

  • createConnection(): establishes a connection to the PostgreSQL database.
  • CreateUser(w http.ResponseWriter, r *http.Request): creates a new user in the database.
  • GetUser(w http.ResponseWriter, r *http.Request): returns a user with the specified ID from the database.
  • GetAllUser(w http.ResponseWriter, r *http.Request): returns all users from the database.
  • UpdateUser(w http.ResponseWriter, r *http.Request): updates a user with the specified ID in the database.
  • DeleteUser(w http.ResponseWriter, r *http.Request): deletes a user with the specified ID from the database.
  • insertUser(user models.User) int64: inserts a new user into the database.
  • getUser(id int64) (models.User, error): returns a user with the specified ID from the database.
  • getAllUsers() ([]models.User, error): returns all users from the database.
  • updateUser(id int64, user models.User) int64: updates a user with the specified ID in the database.
  • deleteUser(id int64) int64: deletes a user with the specified ID from the database.

Dependencies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages