| 35 | } |
| 36 | |
| 37 | func main() { |
| 38 | x := RegexpHandler{} |
| 39 | x.routes = append(x.routes, &route{regexp.MustCompile(`^/\w+-\w+-\w+-\w+-\w+$`), http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 40 | w.WriteHeader(http.StatusNotFound) |
| 41 | })}) |
| 42 | x.routes = append(x.routes, &route{regexp.MustCompile(`^/`), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 43 | w.WriteHeader(http.StatusOK) |
| 44 | if _, err := w.Write([]byte(r.URL.Path)); err != nil { |
| 45 | log.Fatal(err.Error()) |
| 46 | } |
| 47 | })}) |
| 48 | |
| 49 | log.Fatal(http.ListenAndServe("127.0.0.1:8081", &x)) // nolint:gosec |
| 50 | } |