sky-lord-hue / go-userapi-rest

User Information RESTful API on Go: Fiber, MongoDB Atlas

Home Page:https://go-userapi-rest.herokuapp.com/swagger/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User Information RESTful API on Go: Fiber, MongoDB Atlas

go-userapi-rest

Description

REST API for a User Information application in which we create new users, view them, update & delete their information. Here I used a NoSQL database MongoDB for storing the data.

Hosted on Heroku

https://go-userapi-rest.herokuapp.com/swagger/index.html

Requirements

  • Go 1.18

    Rest of requirements are pulled by go itself. Database is already configured but can be changed.

Installation

  1. Clone the repo

    https://github.com/Guleri24/go-userapi-rest.git

  2. Open go-userapi-rest

    cd go-userapi-rest

  3. Install project dependencies

    go get ./...

  4. Optional: Swagger Docs

    swag init

  5. Run

    go run main.go

User

Create a new user

POST /user (Creates a new user)
Parameters
name type data type description
Body required object (JSON) User obj
Example cURL
 curl -X 'POST' 'https://go-userapi-rest.herokuapp.com/api/v1/user' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"address": "Guler, Himachal Pradesh","description": "Student@NITH","dob": "24-12-2000","name": "Guleri"}'

Get user by given ID

GET /user/{id} (Get user by given ID)
Parameters
name type data type description
id required string User ID
Example cURL
 curl -X 'GET' 'https://go-userapi-rest.herokuapp.com/api/v1/user/63023e32606a56bdd637c202' -H 'accept: application/json'

Delete user by given ID

DELETE /user/{id} (Deletes a user by given ID)
Parameters
name type data type description
id required string User ID
Example cURL
 curl -X 'DELETE' 'https://go-userapi-rest.herokuapp.com/api/v1/user/63023e32606a56bdd637c202' -H 'accept: application/json'

Edit/Update user

PATCH /user/{id} (Updates a user by given ID)
Parameters
name type data type description
id required string User Id
Body required object(json) User obj
Example cURL
 curl -X 'PATCH' 'https://go-userapi-rest.herokuapp.com/api/v1/user/63000c7aa8079cb65b7478e7' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"address": "Hostel@DBH","description": "Student@NITH","dob": "24-12-2000","name": "Guleri24"}'

Users

Get all exists users

GET /users (Get all exists users)
Parameters

none

Example cURL
 curl -X 'GET' 'https://go-userapi-rest.herokuapp.com/api/v1/users' -H 'accept: application/json'

About

User Information RESTful API on Go: Fiber, MongoDB Atlas

https://go-userapi-rest.herokuapp.com/swagger/index.html


Languages

Language:Go 98.1%Language:Shell 1.7%Language:Procfile 0.2%