Path
For path processing, you can use Path type. It provides a few useful extra methods to operate with path. Might be helpful in case of using Go's built-in mux router, which doesn't provide path parameters extraction.
Usage:
go
// httpx.Path is a string sub type, so we are wrapping a string path with it.
path := httpx.Path("/foo/bar/baz")
// Tokens returns path tokens, splitted by slash.
path.Tokens() // []string{"foo", "bar", "baz"}
// Get returns path token at the given index.
path.Get(1) // string{"bar"}
// GetAfter returns path token located after provided token.
path.GetAfter("bar") // string{"baz"}
// GetAfterWithIndex returns path token and it's index located after provided token.
path.GetAfterWithIndex("bar") // string{"baz"}, 2
// GetBefore returns path token located before provided token.
path.GetBefore("baz") // string{"bar"}
// GetBeforeWithIndex returns path token and it's index located before provided token.
path.GetBeforeWithIndex("baz") // string{"bar"}, 1