-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
48 lines (36 loc) · 809 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"time"
"github.com/gofiber/fiber/v2/middleware/pprof"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
app.Use(pprof.New())
// Health
app.Get("/", health)
// Define endpoints
app.Get("/append-slice", appendSlice)
app.Get("/hanging-go-routine", hangingGoRoutine)
// Start
err := app.Listen(":8080")
if err != nil {
panic(err)
}
}
func health(c *fiber.Ctx) error {
return c.JSON(map[string]string{
"status": "healthy",
})
}
var globalSlice = make([]int64, 0)
func appendSlice(c *fiber.Ctx) error {
globalSlice = append(globalSlice, time.Now().Unix())
return c.JSON(map[string]int{
"sliceSize": len(globalSlice),
})
}
func hangingGoRoutine(c *fiber.Ctx) error {
go time.Sleep(time.Hour * 24)
return c.SendString("Created a sleeper")
}