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:
Gibheer 2021-05-03 19:43:56 +02:00
parent 8953b10faa
commit eb3dfb3aec
1 changed files with 3 additions and 7 deletions

10
main.go
View File

@ -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))