add initial application structure with configuration, logging, and health check endpoints
This commit is contained in:
3
internal/controller/doc.go
Normal file
3
internal/controller/doc.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package controller
|
||||
|
||||
//go:generate go run ../../cmd/gen/controllers
|
||||
22
internal/controller/health_controller.go
Normal file
22
internal/controller/health_controller.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"epic-ent/internal/service"
|
||||
)
|
||||
|
||||
type HealthController struct {
|
||||
svc *service.HealthService
|
||||
}
|
||||
|
||||
func NewHealthController(svc *service.HealthService) *HealthController {
|
||||
return &HealthController{svc: svc}
|
||||
}
|
||||
|
||||
func (h *HealthController) Health(c echo.Context) error {
|
||||
status := h.svc.Check()
|
||||
return c.JSON(http.StatusOK, status)
|
||||
}
|
||||
13
internal/controller/module.go
Normal file
13
internal/controller/module.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// Code generated by cmd/gen/controllers; DO NOT EDIT.
|
||||
package controller
|
||||
|
||||
import "go.uber.org/fx"
|
||||
|
||||
var Module = fx.Options(
|
||||
fx.Provide(
|
||||
NewHealthController,
|
||||
),
|
||||
fx.Invoke(
|
||||
RegisterRoutes,
|
||||
),
|
||||
)
|
||||
17
internal/controller/routes.go
Normal file
17
internal/controller/routes.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
type RouteParams struct {
|
||||
fx.In
|
||||
|
||||
Echo *echo.Echo
|
||||
Health *HealthController
|
||||
}
|
||||
|
||||
func RegisterRoutes(p RouteParams) {
|
||||
p.Echo.GET("/health", p.Health.Health)
|
||||
}
|
||||
22
internal/controller/user_controller.go
Normal file
22
internal/controller/user_controller.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"epic-ent/internal/service"
|
||||
)
|
||||
|
||||
type UserController struct {
|
||||
svc *service.HealthService
|
||||
}
|
||||
|
||||
func NewUserController(svc *service.HealthService) *HealthController {
|
||||
return &HealthController{svc: svc}
|
||||
}
|
||||
|
||||
func (h *UserController) Health(c echo.Context) error {
|
||||
//status := h.svc.Check()
|
||||
return c.JSON(http.StatusOK, "你好")
|
||||
}
|
||||
Reference in New Issue
Block a user