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

Commit bfc6508

Browse files
added curies
1 parent 48411fc commit bfc6508

3 files changed

Lines changed: 25 additions & 10 deletions

File tree

src/SqlStreamStore.HAL/Constants.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ public static class ContentTypes
2222

2323
public static class Relations
2424
{
25+
public const string StreamStorePrefix = "streamStore";
26+
public const string Curies = "curies";
2527
public const string Self = "self";
2628
public const string First = "first";
2729
public const string Previous = "previous";
2830
public const string Next = "next";
2931
public const string Last = "last";
30-
public const string Index = "streamStore:index";
31-
public const string Feed = "streamStore:feed";
32-
public const string Message = "streamStore:message";
33-
public const string Metadata = "streamStore:metadata";
34-
public const string AppendToStream = "streamStore:append";
35-
public const string Delete = "streamStore:delete";
36-
public const string Find = "streamStore:find";
32+
public const string Index = StreamStorePrefix + ":index";
33+
public const string Feed = StreamStorePrefix + ":feed";
34+
public const string Message = StreamStorePrefix + ":message";
35+
public const string Metadata = StreamStorePrefix + ":metadata";
36+
public const string AppendToStream = StreamStorePrefix + ":append";
37+
public const string Delete = StreamStorePrefix + ":delete";
38+
public const string Find = StreamStorePrefix + ":find";
3739
}
3840

3941
public static class Streams

src/SqlStreamStore.HAL/Links.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public Links AddSelf(string rel, string href, string title = null)
5656

5757
public Link[] ToHalLinks()
5858
{
59-
var links = new Link[_links.Count];
59+
var links = new Link[_links.Count + 1];
6060

6161
for(var i = 0; i < _links.Count; i++)
6262
{
@@ -66,12 +66,25 @@ public Link[] ToHalLinks()
6666
links[i] = new Link(rel, resolvedHref, title, replaceParameters: false);
6767
}
6868

69+
links[_links.Count] = new Link(
70+
Constants.Relations.Curies,
71+
$"{_relativePathToRoot}docs/{{rel}}",
72+
replaceParameters: false)
73+
{
74+
Name = Constants.Relations.StreamStorePrefix
75+
};
76+
6977
return links;
7078
}
7179

7280
public static implicit operator Link[](Links links) => links.ToHalLinks();
7381

74-
private static string FormatLink(string baseAddress, string direction, int maxCount, long position, bool prefetch)
82+
private static string FormatLink(
83+
string baseAddress,
84+
string direction,
85+
int maxCount,
86+
long position,
87+
bool prefetch)
7588
=> $"{baseAddress}?d={direction}&m={maxCount}&p={position}&e={(prefetch ? 1 : 0)}";
7689

7790
public static string FormatForwardLink(string baseAddress, int maxCount, long position, bool prefetch)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace SqlStreamStore.HAL
22
{
3-
internal static class LinkExtensions
3+
internal static class LinksExtensions
44
{
55
public static Links Index(this Links links) =>
66
links.Add(Constants.Relations.Index, string.Empty, "Index");

0 commit comments

Comments
 (0)