Open adhamhf opened 7 years ago
Katharsis has own interceptors too. For your question, Spring interceptors are sitting in spring dispatch servlet. when you configuring Katharsis as a filter, they are in the different branches, so the answer is no. But it's easy to setup Katharsis as a spring controller and make interceptor work. In most case, it's not necessary. Katharsis is focused on Jsonapi, it solves the problem about jsonapi and does it well.
@jianglibo do you have an example of how to setup Katharsis as a Spring Controller and/or how to use Katharsis interceptors?
Reference the KatharsisFilterV2 class and look at the doFilter code, copy all code to your new created class, for example, named "KatharsisProcessor". Because Katharsis's code is clean and tidy, It's a simple job. after that, create a controller like below.
@Controller
public class KatharsisController {
@Autowired
private KatharsisProcessor processor;
@RequestMapping(value="/jsonapi/**")
public void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
try {
processor.process(request, response);
} catch (Exception e) {
e.printStackTrace();
throw(e);
}
}
}
Hmm, That's interesting.
@jianglibo this is great. It's not quite as easy as you suggest, but generally it looks to work. It also solves my other issue because I can have more specific paths for endpoints I want to bypass katharsis. This might be a good example.
Here's the documentation on @RequestMapping and regexes. http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-uri-templates-regex
Is it possible to use Spring interceptors with Katharsis? It seems unlikely since Katharsis ends up bypassing Spring MVC which is what provides interceptors, but I thought I would ask.