本文整理匯總了Golang中github.com/zalando/skipper/filters.FilterContext.ResponseWriter方法的典型用法代碼示例。如果您正苦於以下問題:Golang FilterContext.ResponseWriter方法的具體用法?Golang FilterContext.ResponseWriter怎麽用?Golang FilterContext.ResponseWriter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/zalando/skipper/filters.FilterContext
的用法示例。
在下文中一共展示了FilterContext.ResponseWriter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Response
// Sets the status code and the location header of the response. Marks the
// request served.
func (f *redirect) Response(ctx filters.FilterContext) {
r := ctx.Request()
w := ctx.ResponseWriter()
u := f.copyOfLocation()
if u.Scheme == "" {
if r.URL.Scheme != "" {
u.Scheme = r.URL.Scheme
} else {
u.Scheme = "https"
}
}
u.User = r.URL.User
if u.Host == "" {
u.Host = getRequestHost(r)
}
if u.Path == "" {
u.Path = r.URL.Path
}
if u.RawQuery == "" {
u.RawQuery = r.URL.RawQuery
}
w.Header().Set("Location", u.String())
w.WriteHeader(f.code)
ctx.MarkServed()
}
示例2: Response
// Serves content from the file system and marks the request served.
func (f *static) Response(ctx filters.FilterContext) {
r := ctx.Request()
p := r.URL.Path
if len(p) < len(f.webRoot) {
return
}
ctx.MarkServed()
http.ServeFile(ctx.ResponseWriter(), ctx.Request(), path.Join(f.root, p[len(f.webRoot):]))
}
示例3: Response
// Sets the status code and the location header of the response. Marks the
// request served.
func (f *redirect) Response(ctx filters.FilterContext) {
if !f.deprecated {
return
}
u := getLocation(ctx, f.location)
w := ctx.ResponseWriter()
w.Header().Set("Location", u)
w.WriteHeader(f.code)
ctx.MarkServed()
}