citrusframework / citrusframework/citrus-simulator

Allow CORS mocking

Open
#21 0 comments 2 reactions 0 assignees View on GitHub
Prio: Low READY Type: Enhancement
Dominant language
Java
Stars
47
Forks
45
Avg merge
4d 10h
Merged PRs (30d)
7

Description

It would be nice if the REST simulator had support for mocking / doing CORS.
It's easy enough to do it now by registering a HandlerInterceptor, but it would be nice if this kind of thing could be provided out-of-the-box:
```
public class CorsHandlerInterceptor extends HandlerInterceptorAdapter {

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (CorsUtils.isCorsRequest(request)) {
response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "*");
response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, "*");
if (CorsUtils.isPreFlightRequest(request)) {
return false;
}
}

return true;
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the REST simulator's request handling and the HandlerInterceptorAdapter integration. Review the provided CorsUtils, HttpHeaders, and preflight behavior as the reference for CORS mocking. Done means CORS requests receive the specified headers and preflight requests are handled without reaching the simulator.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.