123456789101112131415161718192021222324252627 |
- package main
- import (
- "fmt"
- "html"
- "log"
- "net/http"
- "strconv"
- router "./core/router"
- )
- func main() {
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- router.Add(`\/(.*)`, func(w http.ResponseWriter, r *http.Request, vars []string) {
- fmt.Println(vars)
- fmt.Fprintf(w, "Hello Route, %q", html.EscapeString(r.URL.Path))
- })
- router.Match(w, r)
- })
- log.Fatal(http.ListenAndServe(":"+strconv.Itoa(SERVER_PORT), nil))
- }
|