No Description

main.go 450B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "fmt"
  4. "html"
  5. "log"
  6. "net/http"
  7. "strconv"
  8. "./core/router"
  9. )
  10. func main() {
  11. http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  12. router.Add(`\/(.*)`, func(w http.ResponseWriter, r *http.Request, vars []string) {
  13. fmt.Println(vars)
  14. fmt.Fprintf(w, "Hello Route, %q", html.EscapeString(r.URL.Path))
  15. })
  16. router.Match(w, r)
  17. })
  18. log.Fatal(http.ListenAndServe(":"+strconv.Itoa(SERVER_PORT), nil))
  19. }