Skip to content

3. Configuration

Max edited this page Feb 2, 2022 · 4 revisions

As you may have seen on other pages, we can create our own result handlers and argument providers.

In order to create an argument provider, we need to implement the HandlerMethodArgumentResolver interface, and in order to create a result handler, we need to implement the HandlerMethodReturnValueHandler interface.

In order to register them, we need to create a configurator class, for this we implement the SpringramConfigurer interface and mark the class with the @Configuration annotation.

@Configuration
public class MySpringramConfigurer implements SpringramConfigurer {
    @Override
    public void configureArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolverList) {
//        argumentResolverList.add(<your implementation of argument resolver>)
    }

    @Override
    public void configureReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
//        returnValueHandlers.add(<your implementation of return value handler>)
    }

    @Override
    public void configurePathMatcher(PathMatchingConfigurer configurer) {
//        configure here something in path matching if your need
    }
}

In the corresponding methods, you can add your own implementations.

Just for example you can check PathVariablesHandlerMethodArgumentResolver and BotApiMethodHandlerMethodReturnValueHandler.

Clone this wiki locally