Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation. Co-Authored-By: Craft Agent <agents-noreply@craft.do>
25 lines
566 B
Go
25 lines
566 B
Go
package httpapi
|
|
|
|
import (
|
|
"log/slog"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func NewRouter() *gin.Engine {
|
|
return NewOperationalRouter(NewOperations(slog.New(slog.NewJSONHandler(os.Stdout, nil))))
|
|
}
|
|
func NewOperationalRouter(ops *Operations) *gin.Engine {
|
|
gin.SetMode(gin.ReleaseMode)
|
|
r := gin.New()
|
|
_ = r.SetTrustedProxies(nil)
|
|
r.Use(ops.Middleware())
|
|
r.NoRoute(func(c *gin.Context) { apiError(c, 404, "not_found", "Not found") })
|
|
r.GET("/api/v1/health/live", func(c *gin.Context) {
|
|
c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
|
})
|
|
return r
|
|
}
|