Update the CORS filter for OPTIONS
Created by: tsodring
Ideally CORS support should just happen in nikita based on spring. It doesn't and I guess the problem is a mis-configuration from my part somewhere. But it would be nice if CORS supported OPTIONS properly.
We want this to aid discoverability. For any HTTP-request/endpoint in the core, we want to be able to hit with an OPTIONS and get back a list of HTTP methods supported for that endpoint. We had a lot of problems getting CORS / OPTIONS supported properly, mainly from lack of understanding.
Currently we deal with discoverability by adding an Allows header on each outgoing HTTP response.
This is handled in
CommonUtils.WebUtils.getMethodsForRequestOrThrow
An example of this can be seen in
no.arkivlab.hioa.nikita.webapp.web.controller.hateoas.BasicRecordHateoasController
return ResponseEntity.status(HttpStatus.CREATED)
.allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath()))
.eTag(createdBasicRecord.getVersion().toString())
.body(basicRecordHateoas);
Another way to handle this is to integrate CommonUtils.WebUtils.getMethodsForRequestOrThrow
with SimpleCORSFilter so that it returns the correct methods for a HTTP request.
Note: I've probably spent more time writing this issue than I would have spent implementing it!