spaceapid/main.go

25 lines
658 B
Go
Raw Normal View History

2023-11-04 20:10:08 +01:00
package main
import (
"log"
"net/http"
"gitlab.hamburg.ccc.de/ccchh/spaceapid/handlers"
"gitlab.hamburg.ccc.de/ccchh/spaceapid/util"
2023-11-04 20:10:08 +01:00
)
func main() {
log.Println("Reading configuration values")
config := util.GetConfiguration()
log.Println("Reading initial SpaceAPI response from", config.TemplatePath)
spaceApiResponse := util.ParseTemplate(config.TemplatePath)
2023-11-04 20:10:08 +01:00
// Register HTTP handlers
http.HandleFunc("/", handlers.Root(&spaceApiResponse))
http.HandleFunc("/state/open", handlers.StateOpen(config.BAUsername, config.BAPassword, &spaceApiResponse))
2023-11-04 20:10:08 +01:00
log.Println("Starting HTTP server...")
log.Fatalln(http.ListenAndServe(":8080", nil))
}