add kontor-api-go REST API with Go, Fiber, Bun
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package handler
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func SetupComics(app *fiber.App) {
|
||||
comics := app.Group("/api/comics")
|
||||
comics.Get("/comics", GetAllComics)
|
||||
}
|
||||
|
||||
func GetAllComics(c *fiber.Ctx) error {
|
||||
return c.Status(200).JSON(&fiber.Map{
|
||||
"comics": []string{},
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package handler
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func GetHealth(c *fiber.Ctx) error {
|
||||
return c.Status(200).JSON(&fiber.Map{
|
||||
"status": "ok",
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"kontor-api-go/cmd/kontor/handler"
|
||||
"log"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("Kontor started")
|
||||
app := fiber.New()
|
||||
|
||||
app.Get("/health", handler.GetHealth)
|
||||
|
||||
handler.SetupComics(app)
|
||||
// Listen on port 8900
|
||||
app.Listen(":8900")
|
||||
|
||||
log.Println("Kontor finished")
|
||||
}
|
||||
Reference in New Issue
Block a user