add example handlers to the server
This is currently work in progress, but shows how the system is intended to work.
This commit is contained in:
parent
8953b10faa
commit
eb3dfb3aec
10
main.go
10
main.go
|
@ -42,7 +42,7 @@ func main() {
|
||||||
|
|
||||||
if cfg.DB.Type != "mysql" && cfg.DB.Type != "postgres" {
|
if cfg.DB.Type != "mysql" && cfg.DB.Type != "postgres" {
|
||||||
log.Fatalf(
|
log.Fatalf(
|
||||||
"unknown database type '%s' in config '%s'. Allowed is 'mysql' and 'postgresql'",
|
"unknown database type '%s' in config '%s'. Allowed is 'mysql' and 'postgres'",
|
||||||
cfg.DB.Type,
|
cfg.DB.Type,
|
||||||
*configPath,
|
*configPath,
|
||||||
)
|
)
|
||||||
|
@ -64,12 +64,8 @@ func main() {
|
||||||
log.Fatalf("could not create server instance: %s", err)
|
log.Fatalf("could not create server instance: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Register("foobar", func(c *Context, req Request, res *Response) error {
|
s.Register("zone_create", zoneCreate)
|
||||||
c.Logf(LevelInfo, "I received a request!")
|
s.Register("zone_list", zoneList)
|
||||||
res.AddMessage(LevelInfo, "Is this working?")
|
|
||||||
res.Result["foo"] = "seems so"
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
http.HandleFunc("/dim", s.Handle)
|
http.HandleFunc("/dim", s.Handle)
|
||||||
log.Fatal(http.ListenAndServe(cfg.Listen, nil))
|
log.Fatal(http.ListenAndServe(cfg.Listen, nil))
|
||||||
|
|
Loading…
Reference in New Issue