コード例 #1
0
        public StaticFileMiddleware(AppFunc next, StaticFileOptions options)
        {
            if (next == null)
            {
                throw new ArgumentNullException("next");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _next     = next;
            _options  = options;
            _matchUrl = options.RequestPath + "/";
        }
コード例 #2
0
ファイル: StaticFileMiddleware.cs プロジェクト: rzontar/pkce
        /// <summary>
        /// Creates a new instance of the StaticFileMiddleware.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="options">The configuration options.</param>
        public StaticFileMiddleware(AppFunc next, StaticFileOptions options)
        {
            if (next == null)
            {
                throw new ArgumentNullException("next");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (options.ContentTypeProvider == null)
            {
                throw new ArgumentException(Resources.Args_NoContentTypeProvider);
            }
            if (options.FileSystem == null)
            {
                options.FileSystem = new PhysicalFileSystem("." + options.RequestPath.Value);
            }

            _next     = next;
            _options  = options;
            _matchUrl = options.RequestPath;
        }
コード例 #3
0
        public StaticFileContext(IDictionary <string, object> environment, StaticFileOptions options, string matchUrl)
        {
            _environment = environment;
            _options     = options;
            _matchUrl    = matchUrl;
            _request     = new OwinRequest(environment);
            _response    = new OwinResponse(environment);

            _method                 = null;
            _isGet                  = false;
            _isHead                 = false;
            _subPath                = null;
            _contentType            = null;
            _fileInfo               = null;
            _length                 = 0;
            _lastModified           = new DateTime();
            _etag                   = null;
            _lastModifiedString     = null;
            _ifMatchState           = PreconditionState.Unspecified;
            _ifNoneMatchState       = PreconditionState.Unspecified;
            _ifModifiedSinceState   = PreconditionState.Unspecified;
            _ifUnmodifiedSinceState = PreconditionState.Unspecified;
        }
コード例 #4
0
ファイル: Startup.cs プロジェクト: jechtom/DevUpdater
        public void Configuration(IAppBuilder app)
        {
            // ioc container
            ResolveContainer();

            // init database
            InitDatabase();

            // synchronize repositories
            container.Resolve<Services.RepositoryService>().Init();

            // authorization
            app.Use<AuthenticationClientCertListMiddleware>(container.Resolve<AuthenticationClientCertListOptions>());

#if DEBUG
            app.UseErrorPage();
#endif

            // setup config
            var config = new System.Web.Http.HttpConfiguration();

            // enable Castle Windsor
            config.Services.Replace(typeof(System.Web.Http.Dispatcher.IHttpControllerActivator), new WindsorCompositionRoot(this.container));

            // routing
            SetUpRouting(config);

            // static files (UI)
            var staticFileOptions = new Microsoft.Owin.StaticFiles.StaticFileOptions() { 
                FileSystem = new EmbeddedResourceFileSystem(this.GetType().Assembly, "DevUpdater.Server.StaticContent")
            };
            app.UseDefaultFiles(new DefaultFilesOptions() { FileSystem = staticFileOptions.FileSystem });
            app.UseStaticFiles(staticFileOptions);

            // web api stuff
            app.UseWebApi(config);
        }
コード例 #5
0
 /// <summary>
 /// Used to look up MIME types given a file path
 /// </summary>
 /// <param name="defaultContentType"></param>
 /// <returns>this</returns>
 public FileServerOptions WithDefaultContentType(string defaultContentType)
 {
     StaticFileOptions.WithDefaultContentType(defaultContentType);
     return(this);
 }
コード例 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="contentTypeProvider"></param>
 /// <returns>this</returns>
 public FileServerOptions WithContentTypeProvider(IContentTypeProvider contentTypeProvider)
 {
     StaticFileOptions.WithContentTypeProvider(contentTypeProvider);
     return(this);
 }