refactor!: Use gin router instead chi router
- Removed chi dependencies - Updated router registration logic
This commit is contained in:
51
main.go
51
main.go
@@ -1,17 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"git.ostiwe.com/ostiwe-com/status/migration"
|
||||
appLog "git.ostiwe.com/ostiwe-com/status/modules/log"
|
||||
"git.ostiwe.com/ostiwe-com/status/pkg/args"
|
||||
"git.ostiwe.com/ostiwe-com/status/router"
|
||||
"git.ostiwe.com/ostiwe-com/status/server"
|
||||
_ "git.ostiwe.com/ostiwe-com/status/settings"
|
||||
"github.com/alexflint/go-arg"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
var appArgs args.AppArgs
|
||||
@@ -34,29 +29,29 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if appArgs.ServerDocumentation != nil {
|
||||
appLog.Global.Get(appLog.SYSTEM).Info("Collect documentation")
|
||||
|
||||
docs := router.Documentate()
|
||||
if !appArgs.ServerDocumentation.Plain {
|
||||
chiRouter := chi.NewRouter()
|
||||
|
||||
err := docs.SetupRoutes(chiRouter, docs)
|
||||
if err != nil {
|
||||
appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Setup docs routes error: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
appLog.Global.Get(appLog.SYSTEM).Info(fmt.Sprintf("Start documentation server on port: %s", appArgs.ServerDocumentation.Port))
|
||||
err = http.ListenAndServe(fmt.Sprintf(":%s", appArgs.ServerDocumentation.Port), chiRouter)
|
||||
if err != nil {
|
||||
appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Startup server error: %v", err))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
// TODO: Rewrite to use gin router, instead of chi router
|
||||
// if appArgs.ServerDocumentation != nil {
|
||||
// appLog.Global.Get(appLog.SYSTEM).Info("Collect documentation")
|
||||
//
|
||||
// docs := router.Documentate()
|
||||
// if !appArgs.ServerDocumentation.Plain {
|
||||
// chiRouter := chi.NewRouter()
|
||||
//
|
||||
// err := docs.SetupRoutes(chiRouter, docs)
|
||||
// if err != nil {
|
||||
// appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Setup docs routes error: %v", err))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// appLog.Global.Get(appLog.SYSTEM).Info(fmt.Sprintf("Start documentation server on port: %s", appArgs.ServerDocumentation.Port))
|
||||
// err = http.ListenAndServe(fmt.Sprintf(":%s", appArgs.ServerDocumentation.Port), chiRouter)
|
||||
// if err != nil {
|
||||
// appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Startup server error: %v", err))
|
||||
// }
|
||||
//
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
|
||||
appLog.Global.Get(appLog.SYSTEM).Info("Exit from application")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user