Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit f53a528

Browse files
uri templates will only work with key value pairs
1 parent 88cc6a5 commit f53a528

7 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/SqlStreamStore.HAL.Tests/AllStreamMessageTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public AllStreamMessageTests()
1515

1616
public void Dispose() => _fixture.Dispose();
1717
private readonly SqlStreamStoreHalMiddlewareFixture _fixture;
18-
private const string HeadOfAll = "../stream?d=b&m=20&p=-1";
18+
private const string HeadOfAll = "../stream?d=b&m=20&p=-1&e=0";
1919

2020
[Fact]
2121
public async Task read_single_message_all_stream()

src/SqlStreamStore.HAL.Tests/CanonicalUrlTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ IEnumerable<string[]> GetPermutations(string[] items, int length)
3131

3232
var d = $"d={(forward ? 'f' : 'b')}";
3333
var m = "m=20";
34-
var e = prefetch ? "e" : null;
34+
var e = $"e={(prefetch ? '1' : '0')}";
3535
var p = "p=0";
3636

3737
var parameters = new[]

src/SqlStreamStore.HAL.Tests/StreamMessageTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public StreamMessageTests()
1515

1616
public void Dispose() => _fixture.Dispose();
1717
private readonly SqlStreamStoreHalMiddlewareFixture _fixture;
18-
private const string HeadOfStream = "../a-stream?d=b&m=20&p=-1";
18+
private const string HeadOfStream = "../a-stream?d=b&m=20&p=-1&e=0";
1919

2020
[Fact]
2121
public async Task read_single_message_stream()

src/SqlStreamStore.HAL.Tests/StreamNavigationTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
public class StreamNavigationTests : IDisposable
1212
{
13-
private const string FirstLinkQuery = "d=f&m=20&p=0";
14-
private const string LastLinkQuery = "d=b&m=20&p=-1";
13+
private const string FirstLinkQuery = "d=f&m=20&p=0&e=0";
14+
private const string LastLinkQuery = "d=b&m=20&p=-1&e=0";
1515

1616
private readonly SqlStreamStoreHalMiddlewareFixture _fixture;
1717

@@ -81,7 +81,7 @@ await _fixture.HttpClient.GetAsync($"{baseAddress}{firstResponse.Headers.Locatio
8181

8282
resource.ShouldLink(Constants.Relations.Last, $"{stream}?{LastLinkQuery}");
8383

84-
resource.ShouldLink(Constants.Relations.Previous, $"{stream}?d=b&m=20&p=9");
84+
resource.ShouldLink(Constants.Relations.Previous, $"{stream}?d=b&m=20&p=9&e=0");
8585

8686
resource.ShouldLink(Constants.Relations.First, $"{stream}?{FirstLinkQuery}");
8787

@@ -136,7 +136,7 @@ public async Task read_first_link_when_multiple_pages(string stream, string base
136136

137137
resource.ShouldLink(Constants.Relations.Last, $"{stream}?{LastLinkQuery}");
138138

139-
resource.ShouldLink(Constants.Relations.Next, $"{stream}?d=f&m=20&p=20");
139+
resource.ShouldLink(Constants.Relations.Next, $"{stream}?d=f&m=20&p=20&e=0");
140140

141141
resource.ShouldLink(Constants.Relations.First, $"{stream}?{FirstLinkQuery}");
142142

src/SqlStreamStore.HAL/Resources/LinkFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace SqlStreamStore.HAL.Resources
33
internal static class LinkFormatter
44
{
55
private static string FormatLink(string baseAddress, string direction, int maxCount, long position, bool prefetch)
6-
=> $"{baseAddress}?d={direction}&m={maxCount}&p={position}{(prefetch ? "&e" : string.Empty)}";
6+
=> $"{baseAddress}?d={direction}&m={maxCount}&p={position}&e={(prefetch ? 1 : 0)}";
77

88
public static string FormatForwardLink(string baseAddress, int maxCount, long position, bool prefetch)
99
=> FormatLink(baseAddress, "f", maxCount, position, prefetch);

src/SqlStreamStore.HAL/Resources/ReadAllStreamOperation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ internal class ReadAllStreamOperation : IStreamStoreOperation<ReadAllPage>
1212

1313
public ReadAllStreamOperation(HttpRequest request)
1414
{
15-
EmbedPayload = request.Query.TryGetValueCaseInsensitive('e', out _);
15+
EmbedPayload = request.Query.TryGetValueCaseInsensitive('e', out var embedPayload)
16+
&& embedPayload == "1";
1617

1718
ReadDirection = request.Query.TryGetValueCaseInsensitive('d', out var readDirection)
1819
&& readDirection == "f" || readDirection == "F"

src/SqlStreamStore.HAL/Resources/ReadStreamOperation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public ReadStreamOperation(HttpRequest request)
1414
{
1515
StreamId = request.Path.Value.Remove(0, 1);
1616

17-
EmbedPayload = request.Query.TryGetValueCaseInsensitive('e', out _);
17+
EmbedPayload = request.Query.TryGetValueCaseInsensitive('e', out var embedPayload)
18+
&& embedPayload == "1";
1819

1920
ReadDirection = request.Query.TryGetValueCaseInsensitive('d', out var readDirection)
2021
&& readDirection == "f" || readDirection == "F"

0 commit comments

Comments
 (0)