private static MidFunc SetStreamMetadata(StreamMetadataResource streamsMetadata)
        => async(context, next) =>
        {
            var operation = await SetStreamMetadataOperation.Create(context);

            var response = await streamsMetadata.Post(operation, context.RequestAborted);

            await context.WriteResponse(response);
        };
        public async Task <Response> Post(
            SetStreamMetadataOperation operation,
            CancellationToken cancellationToken)
        {
            await operation.Invoke(_streamStore, cancellationToken);

            var response = new HalJsonResponse(new HALResponse(new
            {
                operation.StreamId,
                operation.MaxAge,
                operation.MaxCount,
                operation.MetadataJson
            })
                                               .AddLinks(
                                                   Links
                                                   .FromOperation(operation)
                                                   .Index()
                                                   .Find()
                                                   .StreamMetadataNavigation(operation)));

            return(response);
        }