# FastHttpApi **Repository Path**: andyshao/FastHttpApi ## Basic Information - **Project Name**: FastHttpApi - **Description**: 基于dotcore实现的一个高度精简化和高吞吐的HTTP API服务组件,它并没有完全实现HTTP SERVER的所有功能,而是只实现了在APP和WEB中提供数据服务最常用两个指令GET/SET,满足在应用实现JSON,PROTOBUF和MSGPACK等基于HTTP的数据交互功能,虽然是一个精简版本但针对SSL这方面的安全性还是支持。有牺牲就必然有收获,FastHttpApi作出这么大的精简必然在性能上有所收获取,经测试FastHttpApi在GET/POST这些数据交互的场景下性能和吞吐能力是Asp.net core集成的Kestrel的2倍以上. - **Primary Language**: C# - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 30 - **Created**: 2019-03-15 - **Last Updated**: 2022-09-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### introduction Fasthttpapi is a lightweight and high-performance HTTP service component in the dotnet core platform that supports WebSocket and SSL! Performance higher than ap.net web api 200% **[Document](https://ikende.github.io/FastHttpApi/)**. ## Personal blog websites system built on Beetlex.FastHttpApi framework [https://github.com/IKende/XBlog](https://github.com/IKende/XBlog) ## Online case [https://www.ikende.com](https://www.ikende.com) ## PerformanceTest **[master/PerformanceTest](https://github.com/IKende/FastHttpApi/tree/master/PerformanceTest/Beetlex_VS_AspCore_webapi)** ![](https://i.imgur.com/BMj7b4a.png) ## Cluster configuration ### [Cluster configuration project](https://github.com/IKende/ClusterConfiguration) ![](https://camo.githubusercontent.com/a3950a757bd24f331e83dd251d19e1c350ebc7fe/68747470733a2f2f692e696d6775722e636f6d2f7866746a6478352e706e67) ## using ### Install Packet ``` Install-Package BeetleX.FastHttpApi -Version 0.9.9.7 ``` ### Setting Server GC `true` ### sample code ``` [Controller] class Program { private static BeetleX.FastHttpApi.HttpApiServer mApiServer; static void Main(string[] args) { mApiServer = new BeetleX.FastHttpApi.HttpApiServer(); mApiServer.Debug(); mApiServer.Register(typeof(Program).Assembly); mApiServer.Open(); Console.Write(mApiServer.BaseServer); Console.Read(); } // Get /hello?name=henry // or // Get /hello/henry [Get("{name}")] public object Hello(string name) { return $"hello {name} {DateTime.Now}"; } // Get /GetTime public object GetTime() { return DateTime.Now; } // Post /PostStream // name=aaa&value=bbb [Post] [NoDataConvert] public object PostStream(IHttpContext context) { Console.WriteLine(context.Data); string value = context.Request.Stream.ReadString(context.Request.Length); return value; } // Post /Post // {"name":"henry","value":"bbbb"} [Post] public object Post(string name, string value, IHttpContext context) { Console.WriteLine(context.Data); return $"{name}={value}"; } // Post /PostForm // name=aaa&value=bbb [Post] [FormUrlDataConvert] public object PostForm(string name, string value, IHttpContext context) { Console.WriteLine(context.Data); return $"{name}={value}"; } } ``` [samples](https://github.com/IKende/FastHttpApi/tree/master/samples) ## monitoring and management Services #### Install Packet ``` Install-Package BeetleX.FastHttpApi.Admin -Version 0.6.2 ``` #### Registering management controller ``` mApiServer.Register(typeof(BeetleX.FastHttpApi.Admin._Admin).Assembly); ``` ### access url ``` /_admin/index.html ``` ![](https://i.imgur.com/mKrbW43.png) ![](https://i.imgur.com/K7zVzMx.png) ![](https://i.imgur.com/ASTgD2r.png) ![](https://i.imgur.com/q5mf7ee.png)