Ejemplo n.º 1
0
        private void CreateResponse()
        {
            RequestRoute resultRoute;

            // If request is of type file
            if (_httpContext.Request.Uri.IsFile)
            {
                if (_serverContext.HasFileAndDirectoryService)
                {
                    _serverContext.FileAndDirectoryService.SetFileNameAndPathIfFileExists(_serverContext, _httpContext);
                }
            }
            // If request is to type application
            else if (_serverContext.RouteTable.HasRouteToPath(_httpContext.Request.Uri.AbsolutePath, out resultRoute))
            {
                _httpContext.Request.RequestedRoute = resultRoute;
                _httpApplicationHandler.Execute(_httpContext);
                _httpContext.Response.HttpStatusCode = new Ok();
            }
            // If request is to browse file system
            else if (_serverContext.HasFileAndDirectoryService)
            {
                if (_serverContext.FileAndDirectoryService.TryGetDirectoryResultIfDirectoryExists(_serverContext, _httpContext))
                {
                    _httpContext.Response.HttpStatusCode = new Ok();
                }
            }

            // If nothing is found
            if (_httpContext.Response.HttpStatusCode == null)
            {
                _httpContext.Response.HttpStatusCode = new NotFound();
                _httpContext.Response.Data           = "Resource not found";
            }
        }