add fiber app

This commit is contained in:
Mauricio Siu
2024-06-30 20:18:09 -06:00
parent e613f0cae5
commit 4895d3c8ef
10 changed files with 128 additions and 157 deletions

30
go-fiber-simple/main.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"os"
"github.com/gofiber/fiber/v2"
)
func getPort() string {
port := os.Getenv("PORT")
if port == "" {
port = ":3000"
} else {
port = ":" + port
}
return port
}
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.JSON(fiber.Map{
"message": "Hello, Railway!",
})
})
app.Listen(getPort())
}