removed proxy func, need to revist it again

This commit is contained in:
Ankit Patial 2024-11-03 22:33:56 +05:30
parent eda7c79ab6
commit f4a2452a94

View File

@ -144,23 +144,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
r.mux.ServeHTTP(w, req) r.mux.ServeHTTP(w, req)
} }
// Proxy are request and // TODO: proxy for aws lambda
func (r *Router) Proxy(w http.ResponseWriter, req *http.Request) {
if r == nil {
panic("mux: method ServeHTTP called on nil")
}
h, pattern := r.mux.Handler(req)
if pattern == "" {
http.Error(w, "Not Found", http.StatusNotFound)
return
}
// ensure we run all the middlewares
h = stack(r.middlewares, h)
// serve
h.ServeHTTP(w, req)
}
// stack middlewares(http handler) in order they are passed (FIFO) // stack middlewares(http handler) in order they are passed (FIFO)
func stack(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler { func stack(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler {