This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
JSON-API patch extension #4
Comments
There are two hard-coded parameters Lines 144 to 145 in fe8021f
Currently, you can try adding your own controller as follows: @RestController
@RequestMapping(value = "${elide.prefix:/api}")
public class JsonApiPatchExtController {
private static final Logger logger = LoggerFactory.getLogger(JsonApiPatchExtController.class);
private static final String JSON_API_PATCH_EXT_TYPE = "application/vnd.api+json;ext=jsonpatch";
private final Elide elide;
private final ElideProperties elideProperties;
@Autowired
public JsonApiPatchExtController(Elide elide, ElideProperties elideProperties) {
this.elide = elide;
this.elideProperties = elideProperties;
}
@PatchMapping(value = "/**",
consumes = {JSON_API_PATCH_EXT_TYPE},
produces = {JSON_API_PATCH_EXT_TYPE})
public ResponseEntity<String> elidePatch(
@RequestBody String body,
@RequestHeader("Content-Type") String contentType,
@RequestHeader("Accept") String accept,
HttpServletRequest request,
Principal authentication) {
ElideResponse response = elide.patch(contentType, accept,
getJsonApiPath(request, elideProperties.getPrefix()), body, authentication);
return ResponseEntity.status(response.getResponseCode()).body(response.getBody());
}
private static String getJsonApiPath(HttpServletRequest request, String prefix) {
String pathname = (String) request
.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
logger.debug("[{}][{}] forward to elide.", request.getMethod(), pathname);
return pathname.replaceFirst(prefix, "");
}
} |
Yeah might be worthwhile to implement, or perhaps enable it via a setting. I implemented the above controller for now and it works like a charm. Thanks! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hey @olOwOlo, I am looking to utilize Elide's support for bulk writes via their support for the JSON-API patch extension, but it doesn't appear this project will accept/route content using
application/vnd.api+json; ext=jsonpatch
headers. Any suggestions?The text was updated successfully, but these errors were encountered: