Simple start with settings/main page
This commit is contained in:
parent
fe8a7b675f
commit
88f055ded7
|
|
@ -45,6 +45,19 @@ func init() {
|
||||||
flag.IntVar(&port, "port", 80, "port for serving api")
|
flag.IntVar(&port, "port", 80, "port for serving api")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type mainHandler struct {
|
||||||
|
Backend *memoryBackend
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method == http.MethodGet {
|
||||||
|
fmt.Fprintln(w, "<h1>Ekster - Microsub server</h1>")
|
||||||
|
fmt.Fprintln(w, `<p><a href="/settings">Settings</a></p>`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
type hubIncomingBackend struct {
|
type hubIncomingBackend struct {
|
||||||
backend *memoryBackend
|
backend *memoryBackend
|
||||||
}
|
}
|
||||||
|
|
@ -188,6 +201,11 @@ func main() {
|
||||||
http.Handle("/incoming/", &incomingHandler{
|
http.Handle("/incoming/", &incomingHandler{
|
||||||
Backend: &hubBackend,
|
Backend: &hubBackend,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
http.Handle("/", &mainHandler{
|
||||||
|
Backend: backend.(*memoryBackend),
|
||||||
|
})
|
||||||
|
|
||||||
backend.(*memoryBackend).run()
|
backend.(*memoryBackend).run()
|
||||||
log.Printf("Listening on port %d\n", port)
|
log.Printf("Listening on port %d\n", port)
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user