dyndns/webapi/server.go
Torben Nehmer fbf10f9d1b Next implementation steps
- Simplified UpdateRequest to the minimum required
- renamed test user to example
- removed user property from yml config, it is given by the file name.
- splitted server code analogous to command line code so that each handler has its own file.
- made viper confgi in userconfig internal
- added validation to userconfig
- added helper to combaine an IID with a v6net in userconfig
2021-08-23 20:41:32 +02:00

30 lines
561 B
Go

package webapi
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
var router = mux.NewRouter()
func Server() {
router.StrictSlash(true)
router.HandleFunc("/hello", handleHello)
log.Printf("Listening to: %s", C.ListenAddress)
go log.Fatal(http.ListenAndServe(C.ListenAddress, router))
}
func handleHello(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
log.Printf("handleHello %s", r.Host)
log.Println(r.URL)
log.Println(r.Form.Get("Lorem"))
log.Println(r.Form)
fmt.Fprint(w, "<html><body><p>Hello World</p></body></html>")
}