The Employee Leave Management API is a Go language HTTP API built using the GoFr framework. It provides endpoints for managing employee leaves, including operations such as creating a leave request, updating leave details, retrieving leave information, and deleting leave records.
Before running the project, ensure you have the following installed:
- Go (Version 1.16 or later)
- Git
- GoFr
- Make sure to install it using the following command:
go get gofr.dev
- Docker
- To simplify the setup and management of the database for your REST API, consider using a Docker image for SQL.
-
Clone the repository:
git clone https://github.com/Pratishtha33/Go.git
-
change the directory
cd .\Go
-
Install Dependencies:
go get -u ./...
-
Build and Run the Application:
go run main.go
- GoFr seamlessly integrates with GORM for efficient database management. GoFr has ingeniously incorporated various datastores, including PostgreSQL, Redis, MongoDB, SQL and Cassandra, simplifying the process of connecting to and managing different databases.
The Employee Leave Management is an HTTP API that facilitates the management of employee leaves. It provides endpoints to perform CRUD operations on leave records, allowing employee handle employee leave requests.
The codebase is organized into several packages, each serving a specific purpose:
- datastore: Implements the data storage and retrieval logic for leave records.
- handler: Defines HTTP handlers for processing leave-related requests.
- model: Contains data models representing the entities used in the system.
- Represents the data store for leave records.
- Creates a new instance of the leave data store.
- Retrieves a leave record by its ID from the data store.
- Adds a new leave record to the data store.
- Modifies an existing leave record in the data store.
- Removes a leave record from the data store by its ID.
- Implements HTTP handlers for processing leave-related requests.
- Creates a new instance of the leave management handler.
- Handles GET requests to retrieve leave details by ID.
- Handles POST requests to create a new leave record.
- Handles PUT requests to update an existing leave record.
- Handles DELETE requests to delete a leave record.
-
Represents the data model for a leave record.
-
Fields:
ID
: Unique identifier for the leave record.EmployeeID
: Identifier of the associated employee.StartDate
: Start date of the leave.EndDate
: End date of the leave.Reason
: Reason for taking the leave.
- Update
- Read
- Create
- Delete
✅ Run the tests to ensure everything is working correctly.
- Run the following commands to test the coverage, here's a 100% coverage
- Test Handler:
go test ./handler
- Test Datastore:
go test ./datastore