2021-08-15 19:37:11 +00:00
|
|
|
package webapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
2021-08-23 18:41:32 +00:00
|
|
|
var router = mux.NewRouter()
|
|
|
|
|
2021-08-15 19:37:11 +00:00
|
|
|
func Server() {
|
2021-08-23 18:41:32 +00:00
|
|
|
router.StrictSlash(true)
|
2021-08-15 19:37:11 +00:00
|
|
|
|
2021-08-23 18:41:32 +00:00
|
|
|
router.HandleFunc("/hello", handleHello)
|
2021-08-15 19:37:11 +00:00
|
|
|
|
|
|
|
log.Printf("Listening to: %s", C.ListenAddress)
|
2021-08-23 18:41:32 +00:00
|
|
|
go log.Fatal(http.ListenAndServe(C.ListenAddress, router))
|
2021-08-15 19:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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>")
|
|
|
|
}
|