Skip to content

Commit

Permalink
comments on HTTP endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
efumagal committed Aug 8, 2023
1 parent 74c29c1 commit 11aa261
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ func main() {
return c.SendStatus(http.StatusOK)
})

// Hello World HTML page
app.Get("/hello", func(c *fiber.Ctx) error {
c.Set(fiber.HeaderContentType, fiber.MIMETextHTML)
return c.SendString("<h1>Hello, World !</h1>")
})

// Simplified not to pass params and generates random 3D points
app.Get("/distance", func(c *fiber.Ctx) error {
// Create a child span
// Create a child span to show time taken just for the computation
_, childSpan := tracer.Start(c.UserContext(), "distance_computation")
start := geo.NewCoord3d(randFloat(-90, 90), randFloat(-180, 180), randFloat(0, 10000))
end := geo.NewCoord3d(randFloat(-90, 90), randFloat(-180, 180), randFloat(0, 10000))
Expand All @@ -79,6 +81,7 @@ func main() {
return c.JSON(map[string]any{"distance": distance})
})

// Just to simulate a more CPU intensive load
app.Post("/action/cpu-load", func(c *fiber.Ctx) error {
// Create a child span
_, childSpan := tracer.Start(c.UserContext(), "distance_computation")
Expand Down

0 comments on commit 11aa261

Please sign in to comment.