// ServeHTTP returns a simple 404 Not found response
10177
func (notFound) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/plain")
	w.WriteHeader(http.StatusNotFound)
	fmt.Fprint(w, "Not found")

}
1143215
func (f HandlerFunc) ServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request) {
	f(ctx, w, r)
}
115081
func (m *Martini) ServeHTTP(res http.ResponseWriter, req *http.Request) {
	m.createContext(res, req).run()
}
770402
func (r *FlatChain) ServeHTTP(res http.ResponseWriter, req *http.Request) {
	r.Handle(res, req, nil)
}
836077
func (p *Mux) serveHTTP(w http.ResponseWriter, r *http.Request) {

	tree := p.trees[r.Method]

	var h http.HandlerFunc
	var rv *requestVars

	if tree != nil {
		if h, rv = tree.find(r.URL.Path, p); h == nil {

			if p.redirectTrailingSlash && len(r.URL.Path) > 1 {

				// find again all lowercase
				orig := r.URL.Path
				lc := strings.ToLower(orig)

				if lc != r.URL.Path {

					if h, _ = tree.find(lc, p); h != nil {
						r.URL.Path = lc
						h = p.redirect(r.Method, r.URL.String())
						r.URL.Path = orig
						goto END
					}
				}

				if lc[len(lc)-1:] == basePath {
					lc = lc[:len(lc)-1]
				} else {
					lc = lc + basePath
				}

				if h, _ = tree.find(lc, p); h != nil {
					r.URL.Path = lc
					h = p.redirect(r.Method, r.URL.String())
					r.URL.Path = orig
					goto END
				}
			}

		} else {
			goto END
		}
	}

	if p.automaticallyHandleOPTIONS && r.Method == http.MethodOptions {

		if r.URL.Path == "*" { // check server-wide OPTIONS

			for m := range p.trees {

				if m == http.MethodOptions {
					continue
				}

				w.Header().Add(Allow, m)
			}

		} else {

			for m, ctree := range p.trees {

				if m == r.Method || m == http.MethodOptions {
					continue
				}
				if h, _ = ctree.find(r.URL.Path, p); h != nil {
					w.Header().Add(Allow, m)
				}
			}
		}

		w.Header().Add(Allow, http.MethodOptions)
		h = p.httpOPTIONS

		goto END
	}

	if p.handleMethodNotAllowed {

		var found bool

		for m, ctree := range p.trees {

			if m == r.Method {
				continue
			}

			if h, _ = ctree.find(r.URL.Path, p); h != nil {
				w.Header().Add(Allow, m)
				found = true
			}
		}

		if found {
			h = p.http405
			goto END
		}
	}

	// not found
	h = p.http404

END:

	if rv != nil {

		rv.formParsed = false

		// store on context
		r = r.WithContext(rv.ctx)
	}

	h(w, r)

	if rv != nil {
		p.pool.Put(rv)
	}
}
951673
func (f ApiAppHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, app *models.App) {
	f(w, r, app)
}
245284
func (x *XForwarded) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if !x.insecure && !x.isTrustedIP(r.RemoteAddr) {
		for _, h := range xHeaders {
			r.Header.Del(h)
		}
	}

	x.rewrite(r)

	x.next.ServeHTTP(w, r)
}
367984
func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	for _, f := range s.before {
		ctx = f(ctx, r)
	}

	s.proxy.ServeHTTP(w, r)
}
265474
func (w *wrappedMux) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
	w.handler.ServeHTTP(resp, req)
}
777693
func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if r.Method != http.MethodPost {
		w.Header().Set("Content-Type", "text/plain; charset=utf-8")
		w.WriteHeader(http.StatusMethodNotAllowed)
		_, _ = io.WriteString(w, "405 must POST\n")
		return
	}
	ctx := r.Context()

	if s.finalizer != nil {
		iw := &interceptingWriter{w, http.StatusOK}
		defer func() { s.finalizer(ctx, iw.code, r) }()
		w = iw
	}

	for _, f := range s.before {
		ctx = f(ctx, r)
	}

	// Decode the body into an  object
	var req Request
	err := json.NewDecoder(r.Body).Decode(&req)
	if err != nil {
		rpcerr := parseError("JSON could not be decoded: " + err.Error())
		s.logger.Log("err", rpcerr)
		s.errorEncoder(ctx, rpcerr, w)
		return
	}

	// Get the endpoint and codecs from the map using the method
	// defined in the JSON  object
	ecm, ok := s.ecm[req.Method]
	if !ok {
		err := methodNotFoundError(fmt.Sprintf("Method %s was not found.", req.Method))
		s.logger.Log("err", err)
		s.errorEncoder(ctx, err, w)
		return
	}

	// Decode the JSON "params"
	reqParams, err := ecm.Decode(ctx, req.Params)
	if err != nil {
		s.logger.Log("err", err)
		s.errorEncoder(ctx, err, w)
		return
	}

	// Call the Endpoint with the params
	response, err := ecm.Endpoint(ctx, reqParams)
	if err != nil {
		s.logger.Log("err", err)
		s.errorEncoder(ctx, err, w)
		return
	}

	for _, f := range s.after {
		ctx = f(ctx, w)
	}

	res := Response{
		ID:      req.ID,
		JSONRPC: Version,
	}

	// Encode the response from the Endpoint
	resParams, err := ecm.Encode(ctx, response)
	if err != nil {
		s.logger.Log("err", err)
		s.errorEncoder(ctx, err, w)
		return
	}

	res.Result = resParams

	w.Header().Set("Content-Type", ContentType)
	_ = json.NewEncoder(w).Encode(res)
}
109979
func (h configReloadHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	if err := config.ReloadGlobalConfig(); err != nil {
		writeError(w, err)
	} else {
		writeData(w, "success!")
	}
}
463299
func (h *pathHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if exactHandler, ok := h.pathToHandler[r.URL.Path]; ok {
		klog.V(5).Infof("%v: %q satisfied by exact match", h.muxName, r.URL.Path)
		exactHandler.ServeHTTP(w, r)
		return
	}

	for _, prefixHandler := range h.prefixHandlers {
		if strings.HasPrefix(r.URL.Path, prefixHandler.prefix) {
			klog.V(5).Infof("%v: %q satisfied by prefix %v", h.muxName, r.URL.Path, prefixHandler.prefix)
			prefixHandler.handler.ServeHTTP(w, r)
			return
		}
	}

	klog.V(5).Infof("%v: %q satisfied by NotFoundHandler", h.muxName, r.URL.Path)
	h.notFoundHandler.ServeHTTP(w, r)
}
1009278
func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	h, err := m.router.Route(r)
	if err != nil || h == nil {
		m.notFound.ServeHTTP(w, r)
		return
	}
	h.(http.Handler).ServeHTTP(w, r)
}
446629
func (h *WebHookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if err := h.ProcessWebHook(w, r, h.ctx, h.name, h.options.Path); err != nil {
		h.responder.Error(err)
		return
	}
	w.WriteHeader(http.StatusOK)
}
587407
func (fs FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
	if r.Method != "GET" && r.Method != "HEAD" {
		return http.StatusMethodNotAllowed, nil
	}
	return fs.serveFile(w, r)
}
476269
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	c := s.ctxPool.Get(w, r)

	p := r.URL.EscapedPath()
	route, tsr := s.router.Find(r.Method, p, c.pathValues)
	if tsr && s.cfg.RedirectTrailingSlash {
		s.redirect(c, p)
	} else {
		s.execute(c, route)
	}

	s.ctxPool.Put(c)
}
10583
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	iw := newResponseWriter(w)

	createRequestContext(r)
	defer deleteRequestContext(r)

	s.serveHTTP(iw, r)
}