Пример #1
0
        public static IApplicationBuilder UseSqlStreamStoreHal(
            this IApplicationBuilder builder,
            IStreamStore streamStore,
            SqlStreamStoreMiddlewareOptions options = default)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (streamStore == null)
            {
                throw new ArgumentNullException(nameof(streamStore));
            }

            options = options ?? new SqlStreamStoreMiddlewareOptions();

            return(builder
                   .UseExceptionHandling()
                   .Use(CaseSensitiveQueryStrings)
                   .Use(AcceptHalJson)
                   .Use(HeadRequests)
                   .UseIndex()
                   .Map("/stream", UseAllStream(streamStore, options))
                   .Map("/streams", UseStream(streamStore, options)));
        }
Пример #2
0
 private static Action <IApplicationBuilder> UseAllStream(
     IStreamStore streamStore,
     SqlStreamStoreMiddlewareOptions options)
 => builder => builder
 .MapWhen(IsOptions, inner => inner.UseAllStreamOptions(streamStore))
 .UseReadAllStream(streamStore, options)
 .Use(MethodsNotAllowed("POST", "PUT", "DELETE", "TRACE", "PATCH"));
Пример #3
0
 private static Action <IApplicationBuilder> UseStream(
     IStreamStore streamStore,
     SqlStreamStoreMiddlewareOptions options)
 => builder => builder
 .MapWhen(IsOptions, inner => inner.UseStreamOptions(streamStore))
 .UseStreamMetadata(streamStore)
 .UseReadStream(streamStore, options)
 .UseAppendStream(streamStore)
 .UseDeleteStream(streamStore)
 .Use(MethodsNotAllowed("TRACE", "PATCH"));
        public static IApplicationBuilder UseReadStream(
            this IApplicationBuilder builder,
            IStreamStore streamStore,
            SqlStreamStoreMiddlewareOptions options)
        {
            var streams        = new StreamResource(streamStore, options.UseCanonicalUrls);
            var streamMessages = new StreamMessageResource(streamStore);

            return(builder
                   .MapWhen(IsStreamMessage, inner => inner.Use(GetStreamMessage(streamMessages)))
                   .MapWhen(IsStream, inner => inner.Use(GetStream(streams))));
        }
Пример #5
0
        public static IApplicationBuilder UseSqlStreamStoreHal(
            this IApplicationBuilder builder,
            IStreamStore streamStore,
            SqlStreamStoreMiddlewareOptions options = default)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (streamStore == null)
            {
                throw new ArgumentNullException(nameof(streamStore));
            }

            options = options ?? new SqlStreamStoreMiddlewareOptions();

            var index             = new IndexResource(streamStore, options.ServerAssembly);
            var allStream         = new AllStreamResource(streamStore, options.UseCanonicalUrls);
            var allStreamMessages = new AllStreamMessageResource(streamStore);
            var streamBrowser     = new StreamBrowserResource(streamStore);
            var streams           = new StreamResource(streamStore);
            var streamMetadata    = new StreamMetadataResource(streamStore);
            var streamMessages    = new StreamMessageResource(streamStore);
            var documentation     = new DocsResource(
                index,
                allStream,
                allStreamMessages,
                streams,
                streamMessages,
                streamMetadata,
                streamBrowser);

            s_Log.Info(index.ToString);

            return(builder
                   .UseExceptionHandling()
                   .Use(Rfc1738)
                   .Use(HeadRequests)
                   .UseRouter(router => router
                              .MapMiddlewareRoute($"{Constants.Paths.Docs}/{{doc}}", inner => inner.UseDocs(documentation))
                              .MapMiddlewareRoute(Constants.Paths.AllStream, inner => inner.UseAllStream(allStream))
                              .MapMiddlewareRoute($"{Constants.Paths.AllStream}/{{position:long}}",
                                                  inner => inner.UseAllStreamMessage(allStreamMessages))
                              .MapMiddlewareRoute(Constants.Paths.Streams, inner => inner.UseStreamBrowser(streamBrowser))
                              .MapMiddlewareRoute($"{Constants.Paths.Streams}/{{streamId}}", inner => inner.UseStreams(streams))
                              .MapMiddlewareRoute($"{Constants.Paths.Streams}/{{streamId}}/{Constants.Paths.Metadata}",
                                                  inner => inner.UseStreamMetadata(streamMetadata))
                              .MapMiddlewareRoute($"{Constants.Paths.Streams}/{{streamId}}/{{p}}",
                                                  inner => inner.UseStreamMessages(streamMessages))
                              .MapMiddlewareRoute(string.Empty, inner => inner.UseIndex(index))));
        }
Пример #6
0
        public static IApplicationBuilder UseSqlStreamStoreHal(
            this IApplicationBuilder builder,
            IStreamStore streamStore,
            SqlStreamStoreMiddlewareOptions options = default)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (streamStore == null)
            {
                throw new ArgumentNullException(nameof(streamStore));
            }

            options = options ?? new SqlStreamStoreMiddlewareOptions();

            var index             = new IndexResource(streamStore, options.ServerAssembly);
            var allStream         = new AllStreamResource(streamStore, options.UseCanonicalUrls);
            var allStreamMessages = new AllStreamMessageResource(streamStore);
            var streamBrowser     = new StreamBrowserResource(streamStore);
            var streams           = new StreamResource(streamStore);
            var streamMetadata    = new StreamMetadataResource(streamStore);
            var streamMessages    = new StreamMessageResource(streamStore);
            var documentation     = new DocsResource(
                index,
                allStream,
                allStreamMessages,
                streams,
                streamMessages,
                streamMetadata,
                streamBrowser);

            s_Log.Info(index.ToString);

            return(builder
                   .UseExceptionHandling()
                   .Use(CaseSensitiveQueryStrings)
                   .Use(HeadRequests)
                   .UseDocs(documentation)
                   .UseIndex(index)
                   .UseAllStream(allStream)
                   .UseAllStreamMessage(allStreamMessages)
                   .UseStreamBrowser(streamBrowser)
                   .UseStreams(streams)
                   .UseStreamMetadata(streamMetadata)
                   .UseStreamMessages(streamMessages));
        }