mirror of https://github.com/jlelse/GoBlog
Add profile middleware
This commit is contained in:
parent
601c57169a
commit
2e358e2de8
|
@ -20,6 +20,7 @@ type config struct {
|
|||
|
||||
type configServer struct {
|
||||
Logging bool `mapstructure:"logging"`
|
||||
Debug bool `mapstructure:"Debug"`
|
||||
Port int `mapstructure:"port"`
|
||||
Domain string `mapstructure:"domain"`
|
||||
PublicAddress string `mapstructure:"publicAddress"`
|
||||
|
@ -133,6 +134,7 @@ func initConfig() error {
|
|||
return err
|
||||
}
|
||||
viper.SetDefault("server.logging", false)
|
||||
viper.SetDefault("server.debug", false)
|
||||
viper.SetDefault("server.port", 8080)
|
||||
viper.SetDefault("server.publicAddress", "http://localhost:8080")
|
||||
viper.SetDefault("server.publicHttps", false)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
server:
|
||||
logging: false
|
||||
debug: false
|
||||
port: 8080
|
||||
domain: example.com
|
||||
publicAddress: http://localhost:8080
|
||||
|
|
5
http.go
5
http.go
|
@ -63,6 +63,11 @@ func buildHandler() (http.Handler, error) {
|
|||
}
|
||||
r.Use(middleware.Recoverer, middleware.StripSlashes, middleware.GetHead)
|
||||
|
||||
// Profiler
|
||||
if appConfig.Server.Debug {
|
||||
r.Mount("/debug", middleware.Profiler())
|
||||
}
|
||||
|
||||
// API
|
||||
r.Route("/api", func(apiRouter chi.Router) {
|
||||
apiRouter.Use(middleware.BasicAuth("API", map[string]string{
|
||||
|
|
Loading…
Reference in New Issue