コード例 #1
0
ファイル: humastxt.go プロジェクト: hafizh/skipper
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
0
ファイル: requestheader.go プロジェクト: hafizh/skipper
// 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
0
ファイル: filter.go プロジェクト: hafizh/skipper
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
0
ファイル: pathrewrite.go プロジェクト: hafizh/skipper
// 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
0
ファイル: healthcheck.go プロジェクト: hafizh/skipper
func (h *typ) Response(ctx skipper.FilterContext) {
	ctx.Response().StatusCode = 200
}
コード例 #6
0
ファイル: mock.go プロジェクト: hafizh/skipper
func (f *Filter) Response(ctx skipper.FilterContext) {
	copyHeader(ctx.Response().Header, f.ResponseHeaders)
}
コード例 #7
0
ファイル: mock.go プロジェクト: hafizh/skipper
func (f *Filter) Request(ctx skipper.FilterContext) {
	copyHeader(ctx.Request().Header, f.RequestHeaders)
}
コード例 #8
0
ファイル: responseheader.go プロジェクト: hafizh/skipper
// sets the configured header for the response
func (f *impl) Response(ctx skipper.FilterContext) {
	ctx.Response().Header.Add(f.Key(), f.Value())
}