Skip to content

thebitbrine/QuickMan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickMan.Lib

Quick way to build self-hosted APIs

Example:

        private QuickMan API;
        public void Run()
        {
            API = new QuickMan();
            var Endpoints = new Dictionary<string, Action<HttpListenerContext>>();
            
            // Endpoint should not start with a '/'
            // i.e Endpoints.Add("/HelloWorld", HelloWorld); won't work
            // To add an endpoint: Endpoints.Add("EndpointName", EndpointMethod);
            Endpoints.Add("HelloWorld", HelloWorld);
            
            // Server now will start on http://localhost:1999/
            API.Start(Endpoints, 20 /*Maximum Simultaneous Connections*/);
        }

        // http://localhost:1999/HelloWorld
        public void HelloWorld(HttpListenerContext Context)
        {
            // You always have a respond to the request ASAP,
            // otherwise client will drop the connection after ~30 Seconds
            API.Respond("Hello World!", Context);
            Console.WriteLine($"Said 'Hello World!' to {Context.Request.RemoteEndPoint}");
        }

About

Quick way to build self-hosted APIs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages