This commit is contained in:
@@ -12,6 +12,11 @@ type Config struct {
|
||||
Host string `env:"HOST"`
|
||||
DBPath string `env:"DB_PATH"`
|
||||
Auth auth.Config `env:"AUTH"`
|
||||
Web Web `env:"WEB"`
|
||||
}
|
||||
|
||||
type Web struct {
|
||||
Name string `env:"NAME" json:"name"`
|
||||
}
|
||||
|
||||
// Default returns a default configuration with pre-defined values.
|
||||
@@ -26,5 +31,8 @@ func Default() *Config {
|
||||
AdminName: "admin",
|
||||
AdminPassword: "admin",
|
||||
},
|
||||
Web: Web{
|
||||
Name: "ng-blog",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
10
internal/config/service.go
Normal file
10
internal/config/service.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (c *Config) Handle(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(c.Web)
|
||||
}
|
@@ -46,6 +46,8 @@ func app(r *mux.Router, cfg *config.Config) {
|
||||
blg := posts.New(db)
|
||||
auth := auth.New(&cfg.Auth, db)
|
||||
|
||||
// config
|
||||
r.HandleFunc("/conf", cfg.Handle)
|
||||
// auth
|
||||
r.HandleFunc("/auth/login", auth.Login).Methods("POST")
|
||||
r.HandleFunc("/auth/signup", auth.Signup).Methods("POST")
|
||||
|
Reference in New Issue
Block a user