Skip to content

Commit 3cfd70c

Browse files
authored
Merge pull request #41 from futurum-dev/feature/http-range
Support for Http Range
2 parents 3d743b1 + 77b9fa9 commit 3cfd70c

File tree

61 files changed

+869
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+869
-108
lines changed

sample/Futurum.WebApiEndpoint.Sample/Features/ApiEndpointDefinition.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Futurum.ApiEndpoint;
2+
using Futurum.Core.Option;
23
using Futurum.WebApiEndpoint.Metadata;
34
using Futurum.WebApiEndpoint.Sample.Features.CommandWithRequest;
45
using Futurum.WebApiEndpoint.Sample.Features.CommandWithRequestManualParameter;
@@ -32,6 +33,8 @@ public void Configure(ApiEndpointDefinitionBuilder definitionBuilder)
3233
.Query<QueryWithRequestParameterMapFromWithResponseScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-response/{Id}"))
3334
.Query<QueryWithRequestParameterMapFromWithResponseAsyncEnumerableScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-response-async-enumerable/{Id}"))
3435
.Query<QueryWithRequestParameterMapFromWithResponseBytesScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-response-bytes/{Id}"))
36+
.Query<QueryWithRequestParameterMapFromWithResponseBytesRangeScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-response-bytes-range/{Content}"))
37+
.Query<QueryWithRequestParameterMapFromWithResponseBytesOptionRangeScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-response-bytes-option-range/{Content}"))
3538
.Query<QueryWithRequestParameterMapFromWithResponseDataCollectionScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-data-collection/{Id}"))
3639
.Query<QueryWithRequestParameterMapFromWithResponseEmptyJsonScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-response-empty-json/{Id}"))
3740
.Query<QueryWithRequestParameterMapFromWithResponseFileStreamScenario.ApiEndpoint>(builder => builder.Route("query-with-request-parameter-map-from-with-response-file-stream/{Id}"))
@@ -42,6 +45,8 @@ public void Configure(ApiEndpointDefinitionBuilder definitionBuilder)
4245
.Query<QueryWithRequestManualParameterWithResponseScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-response/{Id}", ("Id", MetadataRouteParameterDefinitionType.Path, typeof(string))))
4346
.Query<QueryWithRequestManualParameterWithResponseAsyncEnumerableScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-response-async-enumerable/{Id}", ("Id", MetadataRouteParameterDefinitionType.Path, typeof(string))))
4447
.Query<QueryWithRequestManualParameterWithResponseBytesScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-response-bytes/{Id}", ("Id", MetadataRouteParameterDefinitionType.Path, typeof(string))))
48+
.Query<QueryWithRequestManualParameterWithResponseBytesRangeScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-response-bytes-range/{Content}", ("Content", MetadataRouteParameterDefinitionType.Path, typeof(string)), ("Range", MetadataRouteParameterDefinitionType.Header, typeof(Range))))
49+
.Query<QueryWithRequestManualParameterWithResponseBytesOptionRangeScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-response-bytes-option-range/{Content}", ("Content", MetadataRouteParameterDefinitionType.Path, typeof(string)), ("Range", MetadataRouteParameterDefinitionType.Header, typeof(Option<Range>))))
4550
.Query<QueryWithRequestManualParameterWithResponseDataCollectionScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-data-collection/{Id}", ("Id", MetadataRouteParameterDefinitionType.Path, typeof(string))))
4651
.Query<QueryWithRequestManualParameterWithResponseEmptyJsonScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-response-empty-json/{Id}", ("Id", MetadataRouteParameterDefinitionType.Path, typeof(string))))
4752
.Query<QueryWithRequestManualParameterWithResponseFileStreamScenario.ApiEndpoint>(builder => builder.Route("query-with-request-manual-parameter-with-response-file-stream/{Id}", ("Id", MetadataRouteParameterDefinitionType.Path, typeof(string))))

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequest/CommandWithRequestWithResponseBytesScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ public record Command(string Id);
1212
public class ApiEndpoint : CommandWebApiEndpoint.Request<CommandDto, Command>.ResponseBytes.Mapper<Mapper>
1313
{
1414
public override Task<Result<ResponseBytes>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
15-
new ResponseBytes(File.ReadAllBytes("./Data/hello-world.txt"), $"hello-world-bytes-{request.Id}").ToResultOkAsync();
15+
new ResponseBytes(File.ReadAllBytes("./Data/hello-world.txt"))
16+
{
17+
FileName = $"hello-world-bytes-{request.Id}"
18+
}
19+
.ToResultOkAsync();
1620
}
1721

1822
public class Mapper : IWebApiEndpointRequestMapper<CommandDto, Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequest/CommandWithRequestWithResponseFileStreamWithContentTypeScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ public record Command(string Id);
1212
public class ApiEndpoint : CommandWebApiEndpoint.Request<CommandDto, Command>.ResponseFileStream.Mapper<Mapper>
1313
{
1414
public override Task<Result<ResponseFileStream>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
15-
new ResponseFileStream(new FileInfo("./Data/dotnet-logo.png"), "image/png").ToResultOkAsync();
15+
new ResponseFileStream(new FileInfo("./Data/dotnet-logo.png"))
16+
{
17+
ContentType = "image/png"
18+
}
19+
.ToResultOkAsync();
1620
}
1721

1822
public class Mapper : IWebApiEndpointRequestMapper<CommandDto, Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequest/CommandWithRequestWithResponseStreamScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ public record Command(string Id);
1212
public class ApiEndpoint : CommandWebApiEndpoint.Request<CommandDto, Command>.ResponseStream.Mapper<Mapper>
1313
{
1414
public override Task<Result<ResponseStream>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
15-
new ResponseStream(new FileInfo("./Data/hello-world.txt").OpenRead(), $"hello-world-stream-{request.Id}").ToResultOkAsync();
15+
new ResponseStream(new FileInfo("./Data/hello-world.txt").OpenRead())
16+
{
17+
FileName = $"hello-world-stream-{request.Id}"
18+
}
19+
.ToResultOkAsync();
1620
}
1721

1822
public class Mapper : IWebApiEndpointRequestMapper<CommandDto, Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequestManualParameter/CommandWithRequestManualParameterWithResponseBytesScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ public record Command(string Id);
1010
public class ApiEndpoint : CommandWebApiEndpoint.Request<Command>.ResponseBytes.Mapper<Mapper>
1111
{
1212
public override Task<Result<ResponseBytes>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
13-
new ResponseBytes(File.ReadAllBytes("./Data/hello-world.txt"), $"hello-world-bytes-{request.Id}").ToResultOkAsync();
13+
new ResponseBytes(File.ReadAllBytes("./Data/hello-world.txt"))
14+
{
15+
FileName = $"hello-world-bytes-{request.Id}"
16+
}
17+
.ToResultOkAsync();
1418
}
1519

1620
public class Mapper : IWebApiEndpointRequestMapper<Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequestManualParameter/CommandWithRequestManualParameterWithResponseFileStreamWithContentTypeScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ public record Command(string Id);
1010
public class ApiEndpoint : CommandWebApiEndpoint.Request<Command>.ResponseFileStream.Mapper<Mapper>
1111
{
1212
public override Task<Result<ResponseFileStream>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
13-
new ResponseFileStream(new FileInfo("./Data/dotnet-logo.png"), "image/png").ToResultOkAsync();
13+
new ResponseFileStream(new FileInfo("./Data/dotnet-logo.png"))
14+
{
15+
ContentType = "image/png"
16+
}
17+
.ToResultOkAsync();
1418
}
1519

1620
public class Mapper : IWebApiEndpointRequestMapper<Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequestManualParameter/CommandWithRequestManualParameterWithResponseStreamScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ public record Command(string Id);
1010
public class ApiEndpoint : CommandWebApiEndpoint.Request<Command>.ResponseStream.Mapper<Mapper>
1111
{
1212
public override Task<Result<ResponseStream>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
13-
new ResponseStream(new FileInfo("./Data/hello-world.txt").OpenRead(), $"hello-world-stream-{request.Id}").ToResultOkAsync();
13+
new ResponseStream(new FileInfo("./Data/hello-world.txt").OpenRead())
14+
{
15+
FileName = $"hello-world-stream-{request.Id}"
16+
}
17+
.ToResultOkAsync();
1418
}
1519

1620
public class Mapper : IWebApiEndpointRequestMapper<Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequestParameterMapFrom/CommandWithRequestParameterMapFromWithResponseBytesScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public record Command(string Id);
1515
public class ApiEndpoint : CommandWebApiEndpoint.Request<CommandDto, Command>.ResponseBytes.Mapper<Mapper>
1616
{
1717
public override Task<Result<ResponseBytes>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
18-
new ResponseBytes(File.ReadAllBytes("./Data/hello-world.txt"), $"hello-world-bytes-{request.Id}").ToResultOkAsync();
18+
new ResponseBytes(File.ReadAllBytes("./Data/hello-world.txt"))
19+
{
20+
FileName = $"hello-world-bytes-{request.Id}"
21+
}
22+
.ToResultOkAsync();
1923
}
2024

2125
public class Mapper : IWebApiEndpointRequestMapper<CommandDto, Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequestParameterMapFrom/CommandWithRequestParameterMapFromWithResponseFileStreamWithContentTypeScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public record Command(string Id);
1515
public class ApiEndpoint : CommandWebApiEndpoint.Request<CommandDto, Command>.ResponseFileStream.Mapper<Mapper>
1616
{
1717
public override Task<Result<ResponseFileStream>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
18-
new ResponseFileStream(new FileInfo("./Data/dotnet-logo.png"), "image/png").ToResultOkAsync();
18+
new ResponseFileStream(new FileInfo("./Data/dotnet-logo.png"))
19+
{
20+
ContentType = "image/png"
21+
}
22+
.ToResultOkAsync();
1923
}
2024

2125
public class Mapper : IWebApiEndpointRequestMapper<CommandDto, Command>

sample/Futurum.WebApiEndpoint.Sample/Features/CommandWithRequestParameterMapFrom/CommandWithRequestParameterMapFromWithResponseStreamScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public record Command(string Id);
1515
public class ApiEndpoint : CommandWebApiEndpoint.Request<CommandDto, Command>.ResponseStream.Mapper<Mapper>
1616
{
1717
public override Task<Result<ResponseStream>> ExecuteAsync(Command request, CancellationToken cancellationToken) =>
18-
new ResponseStream(new FileInfo("./Data/hello-world.txt").OpenRead(), $"hello-world-stream-{request.Id}").ToResultOkAsync();
18+
new ResponseStream(new FileInfo("./Data/hello-world.txt").OpenRead())
19+
{
20+
FileName = $"hello-world-stream-{request.Id}"
21+
}
22+
.ToResultOkAsync();
1923
}
2024

2125
public class Mapper : IWebApiEndpointRequestMapper<CommandDto, Command>

0 commit comments

Comments
 (0)