feat: set dev-mode into config
This commit is contained in:
parent
d7eba0a5d6
commit
792ee4ebe0
@ -20,6 +20,8 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
dev-mode: true
|
||||
|
||||
addr: :8080
|
||||
|
||||
db:
|
||||
@ -40,7 +42,6 @@ db:
|
||||
|
||||
log:
|
||||
level: debug
|
||||
development: true
|
||||
disalbe-caller: false
|
||||
disable-stacktrace: false
|
||||
# console or json
|
||||
|
@ -75,7 +75,7 @@ func initConfig() {
|
||||
func logOptions() *log.Options {
|
||||
return &log.Options{
|
||||
Level: viper.GetString("log.level"),
|
||||
Development: viper.GetBool("log.development"),
|
||||
Development: viper.GetBool("dev-mode"),
|
||||
DisableCaller: viper.GetBool("log.disable-caller"),
|
||||
DisableStacktrace: viper.GetBool("log.disable-stacktrace"),
|
||||
Format: viper.GetString("log.format"),
|
||||
|
@ -102,6 +102,13 @@ func run() error {
|
||||
log.InfoLog(string(settings))
|
||||
log.InfoLog(viper.GetString("db.username"))
|
||||
|
||||
isDev := viper.GetBool("dev-mode")
|
||||
if isDev {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
} else {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
r := gin.Default()
|
||||
|
||||
r.GET("/", func(ctx *gin.Context) {
|
||||
|
Loading…
Reference in New Issue
Block a user