func NewVHostPathRewriter(slashesCount int) PathRewriteFunc {
	return func(ctx *RequestCtx) []byte {
		path := stripLeadingSlashes(ctx.Path(), slashesCount)
		host := ctx.Host()
		if n := bytes.IndexByte(host, '/'); n >= 0 {
			host = nil
		}
		if len(host) == 0 {
			host = strInvalidHost
		}
		b := bytebufferpool.Get()
		b.B = append(b.B, '/')
		b.B = append(b.B, host...)
		b.B = append(b.B, path...)
		ctx.URI().SetPathBytes(b.B)
		bytebufferpool.Put(b)

		return ctx.Path()
	}
}
func NewVHostPathRewriter(slashesCount int) PathRewriteFunc {
	return func(ctx *RequestCtx) []byte {
		path := stripLeadingSlashes(ctx.Path(), slashesCount)
		host := ctx.Host()
		if n := bytes.IndexByte(host, '/'); n >= 0 {
			host = nil
		}
		if len(host) == 0 {
			host = strInvalidHost
		}
		b := bytebufferpool.Get()
		b.B = append(b.B, '/')
		b.B = append(b.B, host...)
		b.B = append(b.B, path...)
		ctx.URI().SetPathBytes(b.B)
		bytebufferpool.Put(b)

		return ctx.Path()
	}
}
func NewVHostPathRewriter ( slashesCount int ) PathRewriteFunc { return func ( ctx * RequestCtx ) [ ] byte { path := stripLeadingSlashes ( ctx . Path ( ) , slashesCount ) host := ctx . Host ( ) if n := bytes . IndexByte ( host , '/' ) ; n >= 0 { host = nil } if len ( host ) == 0 { host = strInvalidHost } b := bytebufferpool . Get ( ) b . B = append ( b . B , '/' ) b . B = append ( b . B , host ... ) b . B = append ( b . B , path ... ) ctx . URI ( ) . SetPathBytes ( b . B ) bytebufferpool . Put ( b ) return ctx . Path ( ) } }
// NewVHostPathRewriter returns path rewriter, which strips slashesCount
// leading slashes from the path and prepends the path with request's host,
// thus simplifying virtual hosting for static files.
//
// Examples:
//
//   * host=foobar.com, slashesCount=0, original path="/foo/bar".
//     Resulting path: "/foobar.com/foo/bar"
//
//   * host=img.aaa.com, slashesCount=1, original path="/images/123/456.jpg"
//     Resulting path: "/img.aaa.com/123/456.jpg"
//
NewVHostPathRewriter returns path rewriter which strips slashesCount leading slashes from the path and prepends the path with request s host thus simplifying virtual hosting for static files . Examples : * host = foobar . com slashesCount = 0 original path = / foo / bar . Resulting path : / foobar . com / foo / bar * host = img . aaa . com slashesCount = 1 original path = / images / 123 / 456 . jpg Resulting path : / img . aaa . com / 123 / 456 . jpg