Initial commit — taskboard base (health endpoint)
Gin server on port 8095 with /health route. CRUD task endpoints to be added via plan/62-taskboard-crud. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
40
main.go
Normal file
40
main.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
|
||||
// CORS for local dev
|
||||
r.Use(func(c *gin.Context) {
|
||||
c.Header("Access-Control-Allow-Origin", "*")
|
||||
c.Header("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS")
|
||||
c.Header("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
if c.Request.Method == "OPTIONS" {
|
||||
c.AbortWithStatus(204)
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
})
|
||||
|
||||
r.POST("/tasks", CreateTask)
|
||||
r.GET("/tasks", ListTasks)
|
||||
r.GET("/tasks/:id", GetTask)
|
||||
r.PATCH("/tasks/:id", UpdateTask)
|
||||
r.DELETE("/tasks/:id", DeleteTask)
|
||||
|
||||
r.GET("/health", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"status": "ok"})
|
||||
})
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8095"
|
||||
}
|
||||
|
||||
r.Run(":" + port)
|
||||
}
|
||||
Reference in New Issue
Block a user