-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
30 lines (22 loc) · 862 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
import (
"xyz/datastore" // Import the leave datastore package.
"xyz/handler" // Import the leave management handler package.
"gofr.dev/pkg/gofr"
)
func main() {
// Initialize a new GoFr application.
app := gofr.New()
// Create a new instance of the employee leave datastore.
s := datastore.New()
// Create a new instance of the employee leave management handler.
h := handler.New(s)
// different HTTP methods to perform CRUD operations
app.GET("/leaves/{id}", h.GetByID) // Retrieve leave details by ID
app.POST("/leaves", h.Create) // Create a new leave record
app.PUT("/leaves/{id}", h.Update) // Update an existing leave record
app.DELETE("/leaves/{id}", h.Delete) // Delete a leave record
// Start the server on a custom port
app.Server.HTTP.Port = 8000
app.Start()
}