mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
refactor: simplify interfaces and improve configuration handling
- Removed unused ApiApp and ServerApp interfaces from core/apps/interfaces.go to streamline the codebase. - Updated the GetApi method in the Server struct to return a pointer to the Api type for better type handling. - Simplified the GetGinMode function in core/utils/config.go to always return gin.ReleaseMode, removing unnecessary conditional checks for development mode. - These changes enhance code clarity and maintainability by eliminating redundant code and improving type safety.
This commit is contained in:
@@ -1,26 +1,8 @@
|
||||
package apps
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type App interface {
|
||||
Init()
|
||||
Start()
|
||||
Wait()
|
||||
Stop()
|
||||
}
|
||||
|
||||
type ApiApp interface {
|
||||
App
|
||||
GetGinEngine() (engine *gin.Engine)
|
||||
GetHttpServer() (svr *http.Server)
|
||||
}
|
||||
|
||||
type ServerApp interface {
|
||||
App
|
||||
GetApi() (api ApiApp)
|
||||
GetNodeService() (masterSvc interfaces.NodeService)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func (app *Server) Stop() {
|
||||
app.api.Stop()
|
||||
}
|
||||
|
||||
func (app *Server) GetApi() ApiApp {
|
||||
func (app *Server) GetApi() *Api {
|
||||
return app.api
|
||||
}
|
||||
|
||||
|
||||
@@ -73,11 +73,7 @@ func GetGinMode() string {
|
||||
if res := viper.GetString("gin.mode"); res != "" {
|
||||
return res
|
||||
}
|
||||
if IsDev() {
|
||||
return gin.DebugMode
|
||||
} else {
|
||||
return gin.ReleaseMode
|
||||
}
|
||||
return gin.ReleaseMode
|
||||
}
|
||||
|
||||
func IsPro() bool {
|
||||
|
||||
Reference in New Issue
Block a user