Skip to content

dotnet core high performance and lightweight HTTP server components

License

Notifications You must be signed in to change notification settings

jason000000001/FastHttpApi

 
 

Repository files navigation

introduction

Fasthttpapi is a lightweight and high-performance HTTP service component in the dotnet core platform that supports WebSocket and SSL!HomePage.

master/PerformanceTest

Install Packet

Install-Package BeetleX.FastHttpApi -Version 0.9.9.7

Setting Server GC

<ServerGarbageCollection>true</ServerGarbageCollection>

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
        [RouteTemplate("{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}";
        }
    }

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

About

dotnet core high performance and lightweight HTTP server components

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 82.6%
  • HTML 10.6%
  • JavaScript 6.8%