Giter Site home page Giter Site logo

dynamicwebapi's Introduction

DynamicWebApi

动态创建WebApi
将一般类快速部署为WEBRPC(webapi)


使用方法: 1.安装库 DynamicControllersFactory
2.在webapi服务中添加扩展
services.AddWebApiDirectory();//添加程序集

        //添加服务扩展
        services.AddDynamicWebApi(new DynamicWebApiOptions()  
        {  
            ControllerFeature = (P) => {  

                //注入判断为控制器的类,返回true就是控制器  
                if (P.GetInterface(typeof(ICall).Name) == null)  
                {
                    return false;  
                }  
                return true;  
            }  
        });  

3.可以添加版本信息,映射新的控制器URL名称和域名称
DynamicWebApiOptions有配置项,原理是根据配置值,查找该值的静态字段,常量,获取对应的值进行替换
例如:
ControllerVersion = "vserion", 类常量字段 const string version = "v2";
则路径规则变为:api/v2/控制器名称/方法名称,注意:配置的是字段名称
同理再例如:
ControllerMapName = "MapName",类常量字段 const string MapName= "NewCotroller";
则路径规则变为:api/NewCotroller/方法名称,此时控制器名称被替换

dynamicwebapi's People

Contributors

jinyuttt 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.