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" {
|
||||
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,
|
||||
*configPath,
|
||||
)
|
||||
@ -64,12 +64,8 @@ func main() {
|
||||
log.Fatalf("could not create server instance: %s", err)
|
||||
return
|
||||
}
|
||||
s.Register("foobar", func(c *Context, req Request, res *Response) error {
|
||||
c.Logf(LevelInfo, "I received a request!")
|
||||
res.AddMessage(LevelInfo, "Is this working?")
|
||||
res.Result["foo"] = "seems so"
|
||||
return nil
|
||||
})
|
||||
s.Register("zone_create", zoneCreate)
|
||||
s.Register("zone_list", zoneList)
|
||||
|
||||
http.HandleFunc("/dim", s.Handle)
|
||||
log.Fatal(http.ListenAndServe(cfg.Listen, nil))
|
||||
|
Loading…
Reference in New Issue
Block a user