com.google.sitebricks.http.negotiate
Class RegexNegotiator
java.lang.Object
com.google.sitebricks.http.negotiate.RegexNegotiator
- All Implemented Interfaces:
- ContentNegotiator
public class RegexNegotiator
- extends Object
- implements ContentNegotiator
ContentNegotiator that supports one regex match value, for example
@Accept("(xml|text)/.*") will match any incoming request with an
HTTP Accept header "text/*" and @Referer("(google|yahoo|bing)\\.com") will
match requests with HTTP Referer headers from google, yahoo, or bing
|
Method Summary |
boolean |
shouldCall(Map<String,String> negotiations,
Request request)
Tests whether a given http request (and its headers) should pass against the given
map of content negotiation rules. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RegexNegotiator
public RegexNegotiator()
shouldCall
public boolean shouldCall(Map<String,String> negotiations,
Request request)
- Description copied from interface:
ContentNegotiator
- Tests whether a given http request (and its headers) should pass against the given
map of content negotiation rules.
- Specified by:
shouldCall in interface ContentNegotiator
- Parameters:
negotiations - A Map of header names to match expressions (the value part of an
annotation). For example, an annotation @Accept("text/html") would produce
a map entry of ["Accept" -> "text/html"], assuming that the annotation is mapped via
the SitebricksModule.negotiate(java.lang.String) method to the "Accept"
http header.request - The current http request to match against.
- Returns:
- True if the negotiation succeeded on this method.
Copyright © 2014. All rights reserved.