init bootstrap
This commit is contained in:
47
local/controller/api.go
Normal file
47
local/controller/api.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"omega-server/local/middleware"
|
||||
"omega-server/local/service"
|
||||
"omega-server/local/utl/common"
|
||||
"omega-server/local/utl/error_handler"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type ApiController struct {
|
||||
service *service.ApiService
|
||||
errorHandler *error_handler.ControllerErrorHandler
|
||||
}
|
||||
|
||||
// NewApiController
|
||||
// Initializes ApiController.
|
||||
//
|
||||
// Args:
|
||||
// *services.ApiService: API service
|
||||
// *Fiber.RouterGroup: Fiber Router Group
|
||||
// Returns:
|
||||
// *ApiController: Controller for "api" interactions
|
||||
func NewApiController(as *service.ApiService, routeGroups *common.RouteGroups, auth *middleware.AuthMiddleware) *ApiController {
|
||||
ac := &ApiController{
|
||||
service: as,
|
||||
errorHandler: error_handler.NewControllerErrorHandler(),
|
||||
}
|
||||
|
||||
apiGroup := routeGroups.API
|
||||
apiGroup.Use(auth.Authenticate)
|
||||
apiGroup.Get("/", ac.getFirst)
|
||||
|
||||
return ac
|
||||
}
|
||||
|
||||
// getFirst returns API
|
||||
//
|
||||
// @Summary Return API
|
||||
// @Description Return API
|
||||
// @Tags api
|
||||
// @Success 200 {array} string
|
||||
// @Router /v1/api [get]
|
||||
func (ac *ApiController) getFirst(c *fiber.Ctx) error {
|
||||
return c.SendStatus(fiber.StatusOK)
|
||||
}
|
||||
Reference in New Issue
Block a user