func registerPublicHandlers(mux *http.ServeMux) { mux.Handle(cmdHandler.pattern, &cmdHandler) mux.Handle(pkgHandler.pattern, &pkgHandler) mux.HandleFunc("/doc/codewalk/", codewalk) mux.HandleFunc("/search", search) mux.Handle("/robots.txt", fileServer) mux.HandleFunc("/", serveFile) }
func (s *Server) Run(addr string, mux *http.ServeMux) { s.initServer() mux.Handle("/", s) s.Logger.Printf("web.go serving %s\n", addr) err := http.ListenAndServe(addr, mux) if err != nil { log.Exit("ListenAndServe:", err) } }
func (self *AnonymousPageServer) Attach(s *http.ServeMux) { s.Handle(self.prefix, http.HandlerFunc(func(c *http.Conn, r *http.Request) { _, name := path.Split(r.URL.Path) id, err := strconv.Atoi64(name) if err != nil { c.WriteHeader(http.StatusBadRequest) io.WriteString(c, "invalid page id") } else { self.getPage(id).ServeHTTP(c, r) } })) }
func registerPublicHandlers(mux *http.ServeMux) { mux.Handle(cmdHandler.pattern, &cmdHandler) mux.Handle(pkgHandler.pattern, &pkgHandler) mux.Handle("/search", http.HandlerFunc(search)) mux.Handle("/", http.HandlerFunc(serveFile)) }