zoukankan      html  css  js  c++  java
  • Fd.Service 轻量级WebApi框架

    News

    December 06 2014: Version 1.0.0.8
    Add Register Route 

    Configuration

    iis 7 Integrated Mode:

    <system.webServer>
        <modules>
         <add name="UrlRoutingModule" type="FD.Service.UrlRoutingModule,FD.Service"/>
        </modules>
    </system.webServer>

    iis 6

    <system.web>
     <httpModules>
      <add name="UrlRoutingModule" type="FD.Service.UrlRoutingModule,FD.Service"/>
     </httpModules>
    </system.web>

    Register Service and Route on Global.asax

     protected void Application_Start(object sender, EventArgs e)
            {
                FdRouteTable.RegisterService("FdServiceTest");
    
                FdRouteTable.RegisterRoute(
                    name: "Default",
                    url: "api/{controller}/{action}"
                    );
            }

    Usage

    API Statement:

    [FdService(SessionMode = SessionMode.Support, IsPublicAllMethod = true)]
    [Auth(Message="Login Authorization")]
    public class SchoolApi
    {      
            [FdMethod]
            [Auth(Order = 1, Message = "Authorization")]
            [log(Order = 2, Message = "Log Record")]
            public static int GetPointsByID(int id)
            {
                return 10;
            }
            [FdMethod(ResponseFormat = ResponseFormat.Json)]
            public static List<Student> GetStudentList()
            {
                return new List<Student>()
                {
                    new Student()
                    {
                        Age = 13,
                        Name = "LOKI"
                    },
                    new Student()
                    {
                        Age = 14,
                        Name = "Frigga"
                    }
                };
            }
    }

    Client invoke:

    $.get("/api/SchoolApi/GetPointsByID/", { sid: 101, id: 100 }, function (data) {
                $("#textDetail").append("<br/>GetPointsByID:" + data);
     });

    Installation

    FD.Service can be installed via the nuget UI (as FD.Service), or via the nuget package manager console:

    PM> Install-Package FD.Service

    开源地址:

    https://github.com/mushroomsir/FD.Service

  • 相关阅读:
    ASP.NET中备份恢复数据库
    SQL Server连接失败错误小结
    GSL科学计算库的使用
    [转]VC编程中经常能遇到LNK2005错误
    主函数main中变量(int argc,char *argv[])的含义
    毕业了,工作了
    何为COM组件技术
    一个老外总结的WP开发资源
    跟我一起写Makefile
    qsort() 之 __cdecl
  • 原文地址:https://www.cnblogs.com/mushroom/p/3587870.html
Copyright © 2011-2022 走看看