Clean-up and documentation - #71
Conversation
…s authenticated requests with correct Accept headers
…some historical issues with Link, removing the confusing isLiteral mechanism to cement the expectation that all links in the Seq API are encoded as URI templates, even if they contain zero parameters
Actually, since 5.1.1 already includes quite a bit of churn, might be better to push it through with that. I'll do more testing via the integration harness before #70 goes out the door. |
| public string GetUri(string name) | ||
| { | ||
| return this[name].GetUri(); | ||
| } |
There was a problem hiding this comment.
This method is trivially replaced with its body, with less magic.
| namespace Seq.Api.Serialization | ||
| { | ||
| public class LinkCollectionConverter : JsonConverter | ||
| class LinkCollectionConverter : JsonConverter |
There was a problem hiding this comment.
Since the converter is only used with LinkCollection, and it's plugged in via an attribute, there's no use case for this being public.
| /// Construct a link. | ||
| /// </summary> | ||
| /// <param name="template">The URI template.</param> | ||
| public Link(string template) |
There was a problem hiding this comment.
A link is now strictly a template; the previous isLiteral flag would skip template execution, but this also caused validation to be skipped - GetUri() on an accidentally-flagged isLiteral link wouldn't return a URI but instead a template.
Switching LinkCollectionConverter to use Template directly avoids the redundant template processing during serialization that isLiteral previously provided.
| /// </summary> | ||
| public static Link Empty { get; } = default; | ||
|
|
||
| public Link(string href, IDictionary<string, object> parameters) |
There was a problem hiding this comment.
The parameter-accepting overloads just conflated templates with their instantiated URIs; parameters are now applied in GetUri() only.
This began with an effort to document more of the API of this library, but in doing so I found a few places (mostly historical warts) where the API could be improved.
There are some more changes here, particularly around
Link, which has been simplified quite a bit - it's now always a URI template (and a "literal" URI is represented as a template with no parameters). Some unused constructors were removed - we do use these elsewhere in the Seq codebase, but updating usages and moving theobject->Dictionaryparameter handling to Seq itself if necessary should be straightforward.SeqApiClient.HttpClientnow always includes the API key and (version-identifying)Acceptheader; we always added these for requests made through the library, but requests made directly against the client would not include them (diminishing the value of exposingHttpClientin the first place).Needs some bake-time on
dev:-)