dyndns/webapi/server.go

30 lines
561 B
Go
Raw Normal View History

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>")
}