init repo
This commit is contained in:
28
services/api/handler.go
Normal file
28
services/api/handler.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type APIHandler struct {
|
||||
router *gin.Engine
|
||||
addr []string
|
||||
}
|
||||
|
||||
func NewAPIHandler(addr ...string) *APIHandler {
|
||||
return &APIHandler{
|
||||
addr: addr,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *APIHandler) Init(r *gin.Engine) {
|
||||
h.router = r
|
||||
}
|
||||
|
||||
func (h *APIHandler) Run() {
|
||||
h.router.Run(h.addr...)
|
||||
}
|
||||
|
||||
func (h *APIHandler) GetRouter() *gin.Engine {
|
||||
return h.router
|
||||
}
|
||||
Reference in New Issue
Block a user