HttpServer.Server.Add C# (CSharp) Method

Add() public method

Add a decoder.
Adding zero decoders will make the server add the default ones which is MultiPartDecoder and UrlDecoder.
public Add ( IBodyDecoder decoder ) : void
decoder IBodyDecoder decoder to add
return void
        public void Add(IBodyDecoder decoder)
        {
            _bodyDecoders.Add(decoder);
        }

Same methods

Server::Add ( IHttpListener listener ) : void
Server::Add ( IModule module ) : void
Server::Add ( IRouter router ) : void

Usage Example

        /// <summary>
        /// Initialise a HTTP server
        /// </summary>
        /// <param name="path">The path to the web root of the http server</param>
        public WebServer(string path)
        {
            _httpServer = new HttpServer.Server();

            // Add the controller module and all controllers
            var controllerModule = new RestControllerModule();
            var cType = typeof(RestRequestController);
            AppDomain.CurrentDomain.GetAssemblies().ToList()
                .SelectMany(s => s.GetTypes())
                .Where(p => p.IsSubclassOf(cType) && p != cType && !p.IsAbstract)
                .ToList()
                .ForEach(t => controllerModule.Add((RestRequestController)Activator.CreateInstance(t)));
            _httpServer.Add(controllerModule);

            // Add the basic file module
            int cacheDuration = 2592000;
            Program.Config.TryGetInt("cacheDuration", out cacheDuration);
            var fileModule = new CachedFileModule(Math.Max(0, cacheDuration));
            fileModule.Resources.Add(new HttpServer.Resources.FileResources("/", path));
            _httpServer.Add(fileModule);

            // Set name
            string serverName;
            Program.Config.TryGetString("name", out serverName, "Touchee");
            _httpServer.ServerName = serverName;

            // Go to root
            _httpServer.Add(new SimpleRouter("/", "/index.html"));
        }
All Usage Examples Of HttpServer.Server::Add