JN.MicroHttpServer 1.0.0

Micro Http Server - small http server to be used with other applications such as windows services. In this case, the package could be used do get the service status or send commands to the service.

Install-Package JN.MicroHttpServer -Version 1.0.0
dotnet add package JN.MicroHttpServer --version 1.0.0
<PackageReference Include="JN.MicroHttpServer" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JN.MicroHttpServer --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

JN.MicroHttpServer

Micro Http Server - small http server to be used with other applications such as windows services. In this case, the package could be used do get the service status or send commands to the service.

Install

Download the package from NuGet:

Install-Package JN.MicroHttpServer

Usage

You must create the a configuration containing ConfigItem objects. For each object a DelegateToExecute must be defined to process the requests received for that URL.

The server can be started using Start and stopped with Stop.

Example:


        private IMicroHttpServer GetServer()
        {
            var config = new List<ConfigItem>()
            {
                new ConfigItem()
                {
                    DelegateToExecute = ProcessRequest,
                    HttpMethod = HttpMethod.POST,
                    Uri = "http://localhost:1234/test1/"
                },
                new ConfigItem()
                {
                    DelegateToExecute = ProcessRequest,
                    HttpMethod = HttpMethod.GET,
                    Uri = "http://localhost:1234/test2/"
                }
            };

            var server = new MicroHttpServer(config)
            {
                WriteOutputHandler = Console.WriteLine,
                WriteOutputErrorHandler = Console.WriteLine,
                BasicAuthentication = false
            };

            return server;
        }
		
        private Result ProcessRequest(AccessDetails accessDetails, string content, NameValueCollection queryString)
        {
            //do stuff
            var resultProcessing = DoStuff();
			
            var result = new Result
            {
                Success = true
            };
			
            if(!resultProcessing)
            {
                result.ErrorDescription = "Error Description";
                result.ErrorCode = -1;
                result.Success = false;
            }
			
            return result;
        }
		
        ...
        
        var server = GetServer();
        server.Start();
        ...
        server.Stop();

JN.MicroHttpServer

Micro Http Server - small http server to be used with other applications such as windows services. In this case, the package could be used do get the service status or send commands to the service.

Install

Download the package from NuGet:

Install-Package JN.MicroHttpServer

Usage

You must create the a configuration containing ConfigItem objects. For each object a DelegateToExecute must be defined to process the requests received for that URL.

The server can be started using Start and stopped with Stop.

Example:


        private IMicroHttpServer GetServer()
        {
            var config = new List<ConfigItem>()
            {
                new ConfigItem()
                {
                    DelegateToExecute = ProcessRequest,
                    HttpMethod = HttpMethod.POST,
                    Uri = "http://localhost:1234/test1/"
                },
                new ConfigItem()
                {
                    DelegateToExecute = ProcessRequest,
                    HttpMethod = HttpMethod.GET,
                    Uri = "http://localhost:1234/test2/"
                }
            };

            var server = new MicroHttpServer(config)
            {
                WriteOutputHandler = Console.WriteLine,
                WriteOutputErrorHandler = Console.WriteLine,
                BasicAuthentication = false
            };

            return server;
        }
		
        private Result ProcessRequest(AccessDetails accessDetails, string content, NameValueCollection queryString)
        {
            //do stuff
            var resultProcessing = DoStuff();
			
            var result = new Result
            {
                Success = true
            };
			
            if(!resultProcessing)
            {
                result.ErrorDescription = "Error Description";
                result.ErrorCode = -1;
                result.Success = false;
            }
			
            return result;
        }
		
        ...
        
        var server = GetServer();
        server.Start();
        ...
        server.Stop();

Release Notes

First release.

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0 138 5/4/2019