示例#1
0
文件: godoc.go 项目: WXB506/golang
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)
}
示例#2
0
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)
	}
}
示例#3
0
文件: apage.go 项目: ypb/bwl
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)
		}
	}))
}
示例#4
0
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))
}