Solon2 接口开发: 实战 Gateway 模式效果

1、效果预览

网关

@Mapping("/api/v3/app/**")
@Component
public class ApiGateway3x extends UapiGateway {
    @Override
    protected void register() {
        filter(new BreakerFilter()); //融断

        before(new StartHandler()); //开始计时
        before(new ParamsParseHandler()); //参数解析
        before(new ParamsSignCheckHandler(new Md5Encoder())); //参数签名较验
        before(new ParamsRebuildHandler(new AesDecoder())); //参数重构

        after(new OutputBuildHandler(new AesEncoder())); //输出构建
        after(new OutputSignHandler(new Md5Encoder())); //输出签名
        after(new OutputHandler()); //输出
        after(new EndBeforeLogHandler()); //日志
        after(new EndHandler("v3.api.app")); //结束计时

        //添加一批具体的接口处理Bean
        addBeans(bw -> "api".equals(bw.tag()));
    }
}

接口

@Component(tag = "api")
public class API_config_set extends ApiBase {
    @Inject
    ConfigService configService;

    @NotEmpty({"tag", "key"})
    @Mapping("config.set")
    public void exec(String tag, String key, String value) throws Throwable {
        configService.setConfig(tag, key, value);
    }
}

2、具体参考:

https://gitee.com/noear/marsh/tree/main/_demo/marsh-api-demo2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
有什么问题吗:INFO 2023-07-22 23:43:48.754 [-main][*][o.noear.solon.Solon]: App: Plugin starting INFO 2023-07-22 23:43:48.937 [-main][*][o.noear.solon.Solon]: Session: Local session state plugin is loaded INFO 2023-07-22 23:43:49.256 [-main][*][o.noear.solon.Solon]: View: load: FreemarkerRender INFO 2023-07-22 23:43:49.258 [-main][*][o.noear.solon.Solon]: View: load: org.noear.solon.view.freemarker.FreemarkerRender INFO 2023-07-22 23:43:49.258 [-main][*][o.noear.solon.Solon]: View: mapping: .ftl=FreemarkerRender INFO 2023-07-22 23:43:49.292 [-main][*][o.noear.solon.Solon]: App: Bean scanning INFO 2023-07-22 23:43:50.099 [-main][*][o.noear.solon.Solon]: View: mapping: .html=FreemarkerRender INFO 2023-07-22 23:43:50.995 [-main][*][o.noear.solon.Solon]: Connector:main: undertow: Started ServerConnector@{HTTP/1.1,[http/1.1]}{http://localhost:8080} INFO 2023-07-22 23:43:50.995 [-main][*][o.noear.solon.Solon]: Server:main: undertow: Started (undertow 2.2.24/2.3.8) @893ms INFO 2023-07-22 23:43:50.997 [-main][*][o.noear.solon.Solon]: View: mapping: @json=StringSerializerRender#SnackSerializer INFO 2023-07-22 23:43:50.997 [-main][*][o.noear.solon.Solon]: View: mapping: @type_json=StringSerializerRender#SnackSerializer INFO 2023-07-22 23:43:56.851 [-main][*][c.c.c.InitConfig]: nginxIsRun:false INFO 2023-07-22 23:43:56.899 [-main][*][c.c.c.InitConfig]: runCmd:nginx -c /home/nginxWebUI/nginx.conf INFO 2023-07-22 23:43:57.055 [-main][*][c.c.c.InitConfig]: _ _ __ __ __ __ ____ ____ ____ _ (_)____ _ __| | / /___ / /_ / / / // _/ / __ \ / __ `// // __ \ | |/_/| | /| / // _ \ / __ \ / / / / / / / / / // /_/ // // / / /_> < | |/ |/ // __// /_/ // /_/ /_/ / /_/ /_/ \__, //_//_/ /_//_/|_| |__/|__/ \___//_.___/ \____//___/ /____/
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值