PK NK==Ys" " manifestversion=1.1
frameworkVersions=1.1
PK K=Me e README.md# Play Content Negotiation Module
This module is intended to be used together with the Play! framework. It lets you easily add new
supported content types for clients to consume.
For this clients need to set their Accept header to whatever supported content type they want. See
http://www.playframework.org/modules/cnm for a more complete documentation.
PK K=\T T build.xml
The content negotiation plugin is used to map content types found in the accept header of a HTTP request * to the corresponding response format.
*By default the plugin uses its own content types file to map content types and response format but you * can overwrite this file by specifying your content types mapping using the {@link #CONTENT_TYPES_FILE} * key.
* *Enabling custom content type mappings
*If you want to enable a custom content type like: *
application/vnd.example+xml* to the format
.example
you can write the following into a text file:
* application/vnd.example+xml=example* That way any request whose accept header is set to
application/vnd.example
will be answered
* by templates ending with .example
* To enable the mapping you have to specify the path of your text file inside your
* application/conf
file using the {@linkplain #CONTENT_TYPES_FILE} key:
*
content.types=conf/types*
Loads either the default or a user-defined content type mappings file (a.k.a. properties file).
*/ @Override public void onConfigurationRead() { // Set correct path String path = Play.configuration.getProperty(CONTENT_TYPES_FILE) != null ? Play.configuration.getProperty(CONTENT_TYPES_FILE) : DEFAULT_CONTENT_TYPES_FILE; try { // load properties file from path this.contentTypes = IO.readUtf8Properties(Play.getVirtualFile(path).inputstream()); } catch (RuntimeException exception) { if (exception.getCause() instanceof IOException) { Logger.fatal("Cannot read allowed content types"); System.exit(0); } } } /** *Sets the request format using the {@link #contentTypes content types mapping}.
*/ @Override public void beforeInvocation() { if (this.shouldIntercept()) { // Set the request format to the corresponding value for the current accept header Request.current().format = this.contentTypes.getProperty(Request.current().headers.get(ACCEPT_HEADER).value()); } } /** *Uses the previously set {@link #contentTypes content types} to check whether this plugin should interfere * with the request or not. If no matching content type is found no changes are going to happen. That way we * won't brake any behavior with the existing Play! content type matcher.
* * TODO: Which Play! class is responsible for content type negotiation ATM? * * @returntrue
if an accept header contains any known value, false
otherwise.
*/
private boolean shouldIntercept() {
// Check if the request contains an accept header
if (Request.current().headers.containsKey(ACCEPT_HEADER)) {
// If the request contains an accept header..
// ..check whether the accept header is a known value
if (this.contentTypes.containsKey(Request.current().headers.get(ACCEPT_HEADER).value())) {
// If the request is a known value..
// ..approve!
return true;
}
}
// If the request does not contain an accept header or the value is not known..
// ..deny!
return false;
}
}
PK /K=&l l
conf/types# This is the default content types properties file of the
# Play! Content Negotiation Module.
#
# The content types listed here are only used if you don't
# specify your own content types file in your
# application.conf file using a key named "content.types".
#
# APPLICATION
# ~~~~~~~~~~~
application/atomsvc+xml=atomsvc
application/atom+xml;type\=feed=atomfeed
application/atom+xml;type\=entry=atomentry
application/atom+xml=atomfeed
application/atomcat+xml=atomcat
application/rss+xml=rss
application/xslt+xml=xslt
application/mathml+xml=mathml
application/soap+xml=soap
application/xml-dtd=dtd
application/javascript=js
application/vnd.mozilla.xul+xml=xul
application/x-latex=latex
application/x-tex=tex
application/x-texinfo=texinfo
application/x-vrml=vrml
application/ccxml+xml=ccxml
application/cellml+xml=cellml
application/cnrp+xml=cnrp
application/conference-info+xml=confinfo
application/cpl+xml=cpl
application/davmount+xml=davmount
application/dialog-info+xml=dialoginfo
application/dssc+xml=dssc
application/emma+xml=emma
application/epp+xml=epp
application/exi=exi
application/rdf+xml=rdf
application/vnd.google-earth.kml+xml=kml
application/vnd.syncml+xml=syncml
application/xmpp+xml=xmpp
application/xop+xml=xop
# TEXT
# ~~~~~~~~~~~
text/csv=csv
text/tab-separated-values=tsv
text/x-c=c
text/x-h=h
text/x-fortran=f
text/x-java-source=j
text/x-m=m
text/mcf=mcf
text/pascal=pascal
text/x-asm=asm
text/x-script.scheme=scm
text/sgml=sgml
text/uri-list=uris
text/calendar=ical
text/x-vcalendar=vcs
text/v-card=vcf
# AUDIO
# ~~~~~~~~~~~
audio/x-mpequrl=m3u
PK NK=Wf lib/play-cnm.jarPK
OK= META-INF/ PK
NK=:Hj META-INF/MANIFEST.MFM0E&7PRaC& Зпsm#;.Ph)jG7BfY6,huN[,YjbS^
):3aWg°:HpQ7b&x|+0}PK
NK= play/PK
NK=
play/modules/PK
NK= play/modules/cnm/PK
NK=Ja1 / play.plugins3400*IO)I-Ks+I+KM/L,)M PK
NK=僘 / play/modules/cnm/ContentNegotiationPlugin.classVIsEFG
IPrbaրCe,"/d83ZҘь2ㅭ8p?%P1TA?HdGy[o 0oÛaCxG
{
ѳ
n}APƜe$CR,"cw Ӳr7V*cM0sCpD} r._Meҙ13ڎ04r[7˳zp2 cLn =sdj5OIPəs5H\7Uc6יC ]7uS$cIHP}dn5윖7*hƆfn0S'V5(D5[u,%ڞ`iE aW`5AK8ז5zR: PxEB,nT,( ^TcAN?˷i2^.QZi"2щ/%<-|.,((`(cgbЭDz%Ťfڔf.+FDyW۬e*CEfdX*VѥWveIWoXvy0M5mNhpAF=] snթe%todt%ՙtzlC>w)96fNݬTXYSUՙ.:/hzY77D%5am^,mJJp*E%%kXdNӬm]w80lOV
BadG.sH,
mSCH5|Z<+^9b"^jb`ЭO,2?IiةXN颱R[8M7;:m&=&