com.google.sitebricks.http.negotiate
Class WildcardNegotiator

java.lang.Object
  extended by com.google.sitebricks.http.negotiate.WildcardNegotiator
All Implemented Interfaces:
ContentNegotiator

public class WildcardNegotiator
extends Object
implements ContentNegotiator

ContentNegotiator that supports comma separated and wildcard matches in Accept header style for example, @Accept("text/html, text/plain") will match an incoming request with HTTP Accept header "text/*" and @Accept("text/*") will match incoming request with headers "Accept: text/html" or "Accept: text/plain" Notes: Wildcard for subtypes such as "text/*, image/*" are supported but there is no wildcard matching on the main media types. Negotiating on other HTTP request headers where "/*" might be useful is currently undefined.


Constructor Summary
WildcardNegotiator()
           
 
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
 

Constructor Detail

WildcardNegotiator

public WildcardNegotiator()
Method Detail

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.