...

Source file src/gitlab.com/tslocum/zenith/web.go

Documentation: gitlab.com/tslocum/zenith

     1  package zenith
     2  
     3  import (
     4  	"fmt"
     5  	"html"
     6  	"log"
     7  	"net/http"
     8  )
     9  
    10  func newIndexHandler(tracker *Tracker) func(http.ResponseWriter, *http.Request) {
    11  	return func(w http.ResponseWriter, r *http.Request) {
    12  		// TODO Retrieve top scores
    13  
    14  		fmt.Fprintf(w, "HELLO %d, %q", 0, html.EscapeString(r.URL.RequestURI()))
    15  	}
    16  }
    17  
    18  func hostWebInterface(tracker *Tracker, address string) {
    19  	handler := http.NewServeMux()
    20  
    21  	handler.HandleFunc("/", newIndexHandler(tracker))
    22  
    23  	log.Fatal(http.ListenAndServe(address, handler))
    24  }
    25  

View as plain text