Giter Club home page Giter Club logo

czar.gateway's Introduction

Czar.gateway

项目介绍

Czar网关项目,负责网关相关功能扩展及应用,目前支持mysql、sqlserver两种存储方式,已经实现动态路由、认证、授权、限流、缓存等特性,下一步将会增加日志和监控等功能。

博客同步更新地址

https://www.cnblogs.com/jackcao/

使用方式

public void ConfigureServices(IServiceCollection services)
{
    var authenticationProviderKey = "TestKey";
    Action<IdentityServerAuthenticationOptions> gatewayoptions = o =>
    {
        o.Authority = "http://localhost:7777";
        o.ApiName = "gateway";
        o.RequireHttpsMetadata = false;
    };

    services.AddAuthentication()
        .AddIdentityServerAuthentication(authenticationProviderKey, gatewayoptions);

    Action<IdentityServerAuthenticationOptions> options = o =>
    {
        o.Authority = "http://localhost:7777"; //IdentityServer地址
        o.RequireHttpsMetadata = false;
        o.ApiName = "gateway_admin"; //网关管理的名称,对应的为客户端授权的scope
    };
    services.AddOcelot().AddCzarOcelot(option =>
                                       {
                                           option.DbConnectionStrings = Configuration["CzarConfig:DbConnectionStrings"];
                                           option.RedisConnectionStrings = new List<string>() {        Configuration["CzarConfig:RedisConnectionStrings"]
                                                                                              };
                                           //option.EnableTimer = true;//启用定时任务
                                           //option.TimerDelay = 10 * 000;//周期10秒
                                           option.ClientAuthorization = true;
                                           option.ClientRateLimit = true;
                                       })
        //.UseMySql() //使用mysql
        .AddAdministration("/CzarOcelot", options);
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Error");
    }
    app.UseCzarOcelot().Wait();
}

版本更新记录

0.2.0版本更新记录 初始化项目内容,并统一风格。

0.2.1版本更新记录

修复缓存信息失效后,未从数据库提出最新的配置信息bug。

0.3.0版本更新记录

增加异常信息统一json格式输出

{"errcode":500,"errmsg":"请求服务不可用"}

0.3.1版本更新记录

兼容Ids4自定义的错误输出,并保持风格统一

czar.gateway's People

Contributors

ctrxk avatar jinyancao avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.