// 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 }
// 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) }
// Maps request to it's size in bytes func RequestToBytes(req request.Request) (int64, error) { return req.GetBody().TotalSize() }
// RequestToHost maps request to the host value func RequestToHost(req request.Request) (string, error) { return req.GetHttpRequest().Host, nil }