public async Task <Response> Get( GetStreamMetadataOperation operation, CancellationToken cancellationToken) { var result = await operation.Invoke(_streamStore, cancellationToken); var response = new HalJsonResponse(new HALResponse(new { result.StreamId, result.MetadataStreamVersion, result.MaxAge, result.MaxCount, result.MetadataJson }) .AddLinks( Links .FromOperation(operation) .Index() .Find() .Browse() .StreamMetadataNavigation(operation)) .AddEmbeddedResource( Constants.Relations.Metadata, metadata), result.MetadataStreamVersion >= 0 ? 200 : 404) { Headers = { ETag.FromStreamVersion(result.MetadataStreamVersion) } }; return(response); }
private static MidFunc GetStreamMetadata(StreamMetadataResource streamsMetadata) => async(context, next) => { var operation = new GetStreamMetadataOperation(context); var response = await streamsMetadata.Get(operation, context.RequestAborted); await context.WriteResponse(response); };
public async Task <Response> Get( GetStreamMetadataOperation operation, CancellationToken cancellationToken) { var result = await operation.Invoke(_streamStore, cancellationToken); var response = new HalJsonResponse(new HALResponse(new { result.StreamId, result.MetadataStreamVersion, result.MaxAge, result.MaxCount, MetadataJson = string.IsNullOrEmpty(result.MetadataJson) ? default : JObject.Parse(result.MetadataJson) })