本文整理汇总了Golang中github.com/zalando/skipper/skipper.FilterContext类的典型用法代码示例。如果您正苦于以下问题:Golang FilterContext类的具体用法?Golang FilterContext怎么用?Golang FilterContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilterContext类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Response
func (h *humanstxt) Response(ctx skipper.FilterContext) {
r := ctx.Response()
r.StatusCode = 200
r.Header.Set("Content-Type", "text/plain")
r.Header.Set("Content-Length", strconv.Itoa(len(text)))
r.Body.(io.Writer).Write([]byte(text))
}
示例2: Request
// sets the configured header for the request
func (f *impl) Request(ctx skipper.FilterContext) {
req := ctx.Request()
if f.Key() == "Host" {
req.Host = f.Value()
}
req.Header.Add(f.Key(), f.Value())
}
示例3: Response
func (f *typ) Response(c skipper.FilterContext) {
r := c.Request()
p := r.URL.Path
if len(p) < len(f.webRoot) {
return
}
c.MarkServed()
println("serving static", path.Join(f.root, p[len(f.webRoot):]))
http.ServeFile(c.ResponseWriter(), c.Request(), path.Join(f.root, p[len(f.webRoot):]))
}
示例4: Request
// rewrites the path of the filter
func (f *impl) Request(ctx skipper.FilterContext) {
req := ctx.Request()
req.URL.Path = string(f.rx.ReplaceAll([]byte(req.URL.Path), f.replacement))
}
示例5: Response
func (h *typ) Response(ctx skipper.FilterContext) {
ctx.Response().StatusCode = 200
}
示例6: Response
func (f *Filter) Response(ctx skipper.FilterContext) {
copyHeader(ctx.Response().Header, f.ResponseHeaders)
}
示例7: Request
func (f *Filter) Request(ctx skipper.FilterContext) {
copyHeader(ctx.Request().Header, f.RequestHeaders)
}
示例8: Response
// sets the configured header for the response
func (f *impl) Response(ctx skipper.FilterContext) {
ctx.Response().Header.Add(f.Key(), f.Value())
}