// HeadersFromContext adds headers with values from the request context.
// This is useful for forwarding headers to upstream services.
350943
func HeadersFromContext(headers ...string) Handler {
	return Handler{
		Name: "HeadersFromContext",
		Fn: func(r *Request) {
			for _, header := range headers {
				r.HTTPRequest.Header.Add(header, httpx.Header(r.HTTPRequest.Context(), header))
			}
		},
	}
}
790792
func GetContext(w http.ResponseWriter) (map[interface{}]interface{}, bool) {
	ctxw, ok := GetResponseWriter(w, func(tst http.ResponseWriter) bool {
		_, ok := tst.(*contextResponseWriter)
		return ok
	})
	if ok {
		return ctxw.(*contextResponseWriter).m, true
	}
	return nil, false
}
613874
func SubscribeContext(ctx context.Context) SubscribeOption {
	return func(o *SubscribeOptions) {
		o.Context = ctx
	}
}
589304
func RequestFromContext(ctx context.Context) *Request {
	v := ctx.Value(activeContextKey)
	if v == nil {
		return nil
	}
	return v.(*Request)
}
690937
func (o *GetConsentRequestParams) WithContext(ctx context.Context) *GetConsentRequestParams {
	o.SetContext(ctx)
	return o
}
983921
func (fs *FS) WithContext(ctx context.Context) *FS {
	return &FS{
		ctx:     ctx,
		fsInner: fs.fsInner,
	}
}
517277
func (c *Context) Header(name string) string {
	return c.request.Header.Get(name)
}
867480
func (o *Oauth2TokenParams) WithContext(ctx context.Context) *Oauth2TokenParams {
	o.SetContext(ctx)
	return o
}
1319546
func (h *Error) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	err := h.handler.ServeHTTPContext(ctx, w, r)

	if err != nil {
		f := h.ErrorHandler
		if f == nil {
			f = DefaultErrorHandler
		}

		f(ctx, err, w, r)
	}

	// Pass the error up for any other middleware to use.
	return err
}
325533
func HTTPToContext() http.RequestFunc {
	return func(ctx context.Context, r *stdhttp.Request) context.Context {
		token, ok := extractTokenFromAuthHeader(r.Header.Get("Authorization"))
		if !ok {
			return ctx
		}

		return context.WithValue(ctx, JWTTokenContextKey, token)
	}
}
501422
func HandleContext(ctx context.Context, handler Handler) {
	format, _ := os.LookupEnv("FN_FORMAT")
	if format != "" && format != "http-stream" {
		log.Fatal("only http-stream format is supported, please set function.format=http-stream against your fn service")
	}
	path := os.Getenv("FN_LISTENER")
	startHTTPServer(ctx, handler, path)
}
212723
func RouteFromContext(ctx context.Context) *Route {
	r, _ := ctx.Value(routeKey).(*Route)
	return r
}
617206
func (c *Context) Header(key, value string) {
	if value == "" {
		c.Writer.Header().Del(key)
		return
	}
	c.Writer.Header().Set(key, value)
}
372799
func (c *UpstreamInsertCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}
665262
func (c *UpstreamListCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}
814513
func (f HandlerFunc) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	return f(ctx, w, r)
}
1234080
func addtoContext(r *http.Request, key string, value interface{}) *http.Request {
	ctx := r.Context()
	return r.WithContext(context.WithValue(ctx, key, value))
}