A simple RESTful API built with Go, GORM, and PostgreSQL for performing CRUD operations in my journey of learning Go and getting comfortable with it.
- Go - The programming language used for building the API.
- GORM - An ORM library for Go, used for interacting with the PostgreSQL database.
- PostgreSQL - The relational database management system used for storing and managing note data.
- Create Note: Create a new note by providing title, content, category, and publication status.
- Read Notes: Retrieve a list of all available notes or a specific note by ID.
- Update Note: Update the details (title, content, category, publication status) of an existing note.
- Delete Note: Delete an existing note by providing its ID.
-
Clone the repository:
git clone https://github.com/your-username/go-rest-api.git
-
Copy and set up the PostgreSQL database and update the connection details in the
.env-examplefile:cp .env-example .env
-
Install the dependencies:
go mod download
-
Run the API:
go run main.go
The API will be available at http://localhost:8750.
-
POST /api/auth/register: Register new user -
POST /api/auth/login: Login user -
POST /api/auth/logout: Logout user -
POST /api/notes: Create a new note -
GET /api/notes: Retrieve a list of all notes -
GET /api/notes/:id: Retrieve a specific note by ID -
PUT /api/notes/:id: Update an existing note by ID -
DELETE /api/notes/:id: Delete an existing note by ID
- Add authentication feature for securing the API endpoints.
- Add Role-based access control.
- Implement rate limiting to prevent abuse.
- Using Token Bucket Algorithm
- Add pagination to the
GET /api/notesendpoint. - Write unit and integration tests.
- Implement a search functionality for notes.
- Add Swagger documentation for the API.
- Set up a CI/CD pipeline for automated testing and deployment.