com.github.datalking.web.http.accept.ParameterContentNegotiationStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of play-mvc Show documentation
Show all versions of play-mvc Show documentation
simple mvc framework based on java servlet.
The newest version!
package com.github.datalking.web.http.accept;
import com.github.datalking.util.Assert;
import com.github.datalking.web.context.request.WebRequest;
import com.github.datalking.web.http.MediaType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
/**
*/
public class ParameterContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy {
private static final Logger logger = LoggerFactory.getLogger(ParameterContentNegotiationStrategy.class);
private String parameterName = "format";
public ParameterContentNegotiationStrategy(Map mediaTypes) {
super(mediaTypes);
}
public void setParameterName(String parameterName) {
Assert.notNull(parameterName, "parameterName is required");
this.parameterName = parameterName;
}
@Override
protected String getMediaTypeKey(WebRequest webRequest) {
return webRequest.getParameter(this.parameterName);
}
@Override
protected void handleMatch(String mediaTypeKey, MediaType mediaType) {
if (logger.isDebugEnabled()) {
logger.debug("Requested media type is " + mediaType + " based on parameter" + mediaTypeKey + "')");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy