Пример #1
0
// RequestToClientIp is a TokenMapper that maps the request to the client IP.
func RequestToClientIp(req request.Request) (string, error) {
	vals := strings.SplitN(req.GetHttpRequest().RemoteAddr, ":", 2)
	if len(vals[0]) == 0 {
		return "", fmt.Errorf("Failed to parse client IP")
	}
	return vals[0], nil
}
Пример #2
0
// Takes the request and returns the location if the request path matches any of it's paths
// returns nil if none of the requests matches
func (p *trie) match(r request.Request) location.Location {
	if p.root == nil {
		return nil
	}

	path := r.GetHttpRequest().URL.Path
	if len(path) == 0 {
		path = "/"
	}
	return p.root.match(-1, path, r)
}
Пример #3
0
// Maps request to it's size in bytes
func RequestToBytes(req request.Request) (int64, error) {
	return req.GetBody().TotalSize()
}
Пример #4
0
// RequestToHost maps request to the host value
func RequestToHost(req request.Request) (string, error) {
	return req.GetHttpRequest().Host, nil
}