Skip to content

Commit

Permalink
Revert "REST: Initial cut of 'respond' method and Renderer abstractio…
Browse files Browse the repository at this point in the history
…n. Still very basic and evolving."

This reverts commit c090aef.
  • Loading branch information
graemerocher committed May 25, 2013
1 parent e33288f commit 5b42ca0
Show file tree
Hide file tree
Showing 24 changed files with 10 additions and 967 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void performInjection(SourceUnit source, GeneratorContext context, ClassN
}
else if (requiresAutowiring()) {

PropertyNode propertyNode = new PropertyNode(apiInstanceProperty, Modifier.PUBLIC, implementationNode, classNode, null, null, null);
PropertyNode propertyNode = new PropertyNode(apiInstanceProperty, Modifier.PUBLIC, implementationNode, classNode, new ConstructorCallExpression(implementationNode, ZERO_ARGS), null, null);
propertyNode.addAnnotation(AUTO_WIRED_ANNOTATION);
if(getMarkerAnnotation() != null) {
propertyNode.addAnnotation(getMarkerAnnotation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,12 @@ class ResponseMimeTypesApi {
final webRequest = GrailsWebRequest.lookup()
HttpServletRequest request = webRequest.getCurrentRequest()
def result = request.getAttribute(GrailsApplicationAttributes.RESPONSE_FORMAT)
if (!result) {
final mimeType = getMimeType(response)
if (mimeType) {
result = mimeType.extension
request.setAttribute(GrailsApplicationAttributes.RESPONSE_FORMAT, result)
}
}
return result
}

/**
* Obtains the MimeType for the response using either the file extension or the ACCEPT header
*
* @param response The response
* @return The MimeType
*/
MimeType getMimeType(HttpServletResponse response) {

final webRequest = GrailsWebRequest.lookup()
HttpServletRequest request = webRequest.getCurrentRequest()
MimeType result = (MimeType)request.getAttribute(GrailsApplicationAttributes.RESPONSE_MIME_TYPE)
if (!result) {
def formatOverride = webRequest?.params?.format
if (!formatOverride) {
formatOverride = request.getAttribute(GrailsApplicationAttributes.RESPONSE_FORMAT)
}
if (formatOverride) {
def allMimes = getMimeTypes()
MimeType mime = allMimes.find { MimeType it -> it.extension == formatOverride }
result = mime ? mime : getMimeTypes()[0]
result = mime ? mime.extension : getMimeTypes()[0].extension

// Save the evaluated format as a request attribute.
// This is a blatant hack because we should to this
Expand All @@ -115,10 +91,10 @@ class ResponseMimeTypesApi {
// - which initialises the CONTENT_FORMAT attribute
// - *before* the "format" parameter is added to the map
// - so the saved format is wrong
request.setAttribute(GrailsApplicationAttributes.RESPONSE_MIME_TYPE, result)
request.setAttribute(GrailsApplicationAttributes.RESPONSE_FORMAT, result)
}
else {
result = getMimeTypesInternal(request, response)[0]
result = getMimeTypesInternal(request, response)[0].extension
}
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ class DefaultAcceptHeaderParser implements AcceptHeaderParser {

// remove duplicate text/xml and application/xml entries
MimeType textXml = mimes.find { MimeType it -> it.name == 'text/xml' }
MimeType appXml = mimes.find { MimeType it -> it.name == MimeType.XML.name }
MimeType appXml = mimes.find { MimeType it -> it.name == MimeType.XML }
if (textXml && appXml) {
// take the largest q value
appXml.parameters.q = [textXml.parameters.q.toBigDecimal(), appXml.parameters.q.toBigDecimal()].max()

mimes.remove(textXml)
}
else if (textXml) {
textXml.name = MimeType.XML.name
textXml.name = MimeType.XML
}

if (appXml) {
Expand Down
6 changes: 0 additions & 6 deletions grails-plugin-rest/build.gradle

This file was deleted.

28 changes: 0 additions & 28 deletions grails-plugin-rest/src/main/groovy/grails/rest/Resource.groovy

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5b42ca0

Please sign in to comment.