All Downloads are FREE. Search and download functionalities are using the official Maven repository.

colesico.framework.rpc.internal.RpcRouterOptions Maven / Gradle / Ivy

The newest version!
package colesico.framework.rpc.internal;

import colesico.framework.config.Config;
import colesico.framework.http.HttpMethod;
import colesico.framework.router.RouterBuilder;
import colesico.framework.router.RouterOptions;
import colesico.framework.rpc.teleapi.RpcExchange;

import javax.inject.Inject;

@Config
public class RpcRouterOptions extends RouterOptions {

    public static final String RPC_DISPATCHER_ROUTE = "/rpc";

    private final RpcDispatcher dispatcher;
    private final RpcExchange exchange;

    @Inject
    public RpcRouterOptions(RpcDispatcher dispatcher, RpcExchange exchange) {
        this.dispatcher = dispatcher;
        this.exchange = exchange;
    }

    @Override
    public void applyOptions(RouterBuilder builder) {
        builder.addCustomAction(HttpMethod.HTTP_METHOD_POST,
                RPC_DISPATCHER_ROUTE,
                () -> dispatcher.dispatch(exchange),
                RpcDispatcher.class,
                "dispatch",
                null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy