コード例 #1
0
ファイル: Program.cs プロジェクト: yanbingms/SimpleHttpServer
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            var route_config = new List<Models.Route>() {
                new Route {
                    Name = "Hello Handler",
                    UrlRegex = @"^/$",
                    Method = "GET",
                    Callable = (HttpRequest request) => {
                        return new HttpResponse()
                        {
                            ContentAsUTF8 = "Hello from SimpleHttpServer",
                            ReasonPhrase = "OK",
                            StatusCode = "200"
                        };
                     }
                },
                //new Route {
                //    Name = "FileSystem Static Handler",
                //    UrlRegex = @"^/Static/(.*)$",
                //    Method = "GET",
                //    Callable = new FileSystemRouteHandler() { BasePath = @"C:\Tmp", ShowDirectories=true }.Handle,
                //},
            };

            HttpServer httpServer = new HttpServer(8080, route_config);

            Thread thread = new Thread(new ThreadStart(httpServer.Listen));
            thread.Start();
        }
コード例 #2
0
 // Konstruktor
 public HttpProcessor(TcpClient s, HttpServer srv)
 {
     this.mySocket = s;
     this.myServer = srv;
 }