diff --git a/benchmarks/Responders/OkResponder.cs b/benchmarks/Responders/OkResponder.cs index cd21b9e..1c346a7 100644 --- a/benchmarks/Responders/OkResponder.cs +++ b/benchmarks/Responders/OkResponder.cs @@ -11,6 +11,6 @@ namespace HyperSharp.Benchmarks.Responders { public static Type[] Needs => Type.EmptyTypes; - public Result Respond(HyperContext context, CancellationToken cancellationToken = default) => Result.Success(new HyperStatus(HttpStatusCode.OK)); + public Result Respond(HyperContext context, CancellationToken cancellationToken = default) => Result.Success(HyperStatus.OK()); } } diff --git a/benchmarks/Responders/OkTaskResponder.cs b/benchmarks/Responders/OkTaskResponder.cs index 372589c..2bd7044 100644 --- a/benchmarks/Responders/OkTaskResponder.cs +++ b/benchmarks/Responders/OkTaskResponder.cs @@ -14,7 +14,7 @@ namespace HyperSharp.Benchmarks.Responders public async Task> RespondAsync(HyperContext context, CancellationToken cancellationToken = default) { - await context.RespondAsync(new HyperStatus(HttpStatusCode.OK), HyperSerializers.PlainTextAsync, cancellationToken); + await context.RespondAsync(HyperStatus.OK(), HyperSerializers.PlainTextAsync, cancellationToken); return Result.Success(default(HyperStatus)); } } diff --git a/src/HyperSharp.SourceGeneration/src/Tasks/HyperStatusConstructorGenerator.cs b/src/HyperSharp.SourceGeneration/src/Tasks/HyperStatusConstructorGenerator.cs index 04b1b77..5ab28ea 100644 --- a/src/HyperSharp.SourceGeneration/src/Tasks/HyperStatusConstructorGenerator.cs +++ b/src/HyperSharp.SourceGeneration/src/Tasks/HyperStatusConstructorGenerator.cs @@ -23,20 +23,57 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus {{Code}}() => new(global::System.Net.HttpStatusCode.{{Code}}, new HyperHeaderCollection(), null); + public static HyperStatus {{Code}}() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.{{Code}} + }; /// /// The body of the response. - public static HyperStatus {{Code}}(object? body) => new(global::System.Net.HttpStatusCode.{{Code}}, new HyperHeaderCollection(), body); + public static HyperStatus {{Code}}(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.{{Code}}, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus {{Code}}(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.{{Code}}, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus {{Code}}(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.{{Code}}, headers, null); + public static HyperStatus {{Code}}(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.{{Code}}, + Headers = headers + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus {{Code}}(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.{{Code}}, headers, body); + public static HyperStatus {{Code}}(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.{{Code}}, + Headers = headers, + Body = body + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus {{Code}}(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.{{Code}}, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/HyperConfiguration.cs b/src/HyperSharp/HyperConfiguration.cs index acde9e5..1be2784 100644 --- a/src/HyperSharp/HyperConfiguration.cs +++ b/src/HyperSharp/HyperConfiguration.cs @@ -55,31 +55,30 @@ public sealed record HyperConfiguration /// /// Creates a new with the default values. /// - public HyperConfiguration() : this(new ServiceCollection().AddLogging(builder => builder.AddProvider(NullLoggerProvider.Instance)).AddHyperSharp(), new HyperConfigurationBuilder()) { } + public HyperConfiguration() : this(new ServiceCollection().AddLogging(builder => builder.AddProvider(NullLoggerProvider.Instance)).AddHyperSharp().BuildServiceProvider(), new HyperConfigurationBuilder()) { } /// /// Creates a new with the specified values. /// /// The to use. - public HyperConfiguration(HyperConfigurationBuilder builder) : this(new ServiceCollection().AddLogging(builder => builder.AddProvider(NullLoggerProvider.Instance)).AddHyperSharp(), builder) { } + public HyperConfiguration(HyperConfigurationBuilder builder) : this(new ServiceCollection().AddLogging(builder => builder.AddProvider(NullLoggerProvider.Instance)).AddHyperSharp().BuildServiceProvider(), builder) { } /// /// Creates a new using the specified . /// /// The to use when creating the responders. - public HyperConfiguration(IServiceCollection serviceDescriptors) : this(serviceDescriptors, new HyperConfigurationBuilder()) { } + public HyperConfiguration(IServiceCollection serviceDescriptors) : this(serviceDescriptors.BuildServiceProvider(), new HyperConfigurationBuilder()) { } /// /// Creates a new using the specified and . /// - /// The to use when creating the responders. + /// The to use. /// The to use. - public HyperConfiguration(IServiceCollection serviceDescriptors, HyperConfigurationBuilder builder) + public HyperConfiguration(IServiceProvider serviceProvider, HyperConfigurationBuilder builder) { - ArgumentNullException.ThrowIfNull(serviceDescriptors, nameof(serviceDescriptors)); + ArgumentNullException.ThrowIfNull(serviceProvider, nameof(serviceProvider)); ArgumentNullException.ThrowIfNull(builder, nameof(builder)); - IServiceProvider serviceProvider = serviceDescriptors.BuildServiceProvider(); if (!Uri.TryCreate($"http://{builder.ListeningEndpoint}/", UriKind.Absolute, out Uri? host)) { throw new ArgumentException("The listening endpoint is invalid.", nameof(builder)); diff --git a/src/HyperSharp/HyperServer.cs b/src/HyperSharp/HyperServer.cs index a6a85ad..198e18b 100644 --- a/src/HyperSharp/HyperServer.cs +++ b/src/HyperSharp/HyperServer.cs @@ -178,7 +178,7 @@ private async Task HandleConnectionAsync(Ulid id, NetworkStream networkStream) _ => throw new NotImplementedException("Unimplemented result status, please open a GitHub issue as this is a bug.") }; - await context.Value.RespondAsync(response, HyperSerializers.JsonAsync, cancellationTokenSource.Token); + await context.Value.RespondAsync(response, cancellationTokenSource.Token); HyperLogging.HttpResponded(_logger, connection.Id, response, null); } } diff --git a/src/HyperSharp/Protocol/HyperContext.cs b/src/HyperSharp/Protocol/HyperContext.cs index 655a136..b46ee18 100644 --- a/src/HyperSharp/Protocol/HyperContext.cs +++ b/src/HyperSharp/Protocol/HyperContext.cs @@ -105,7 +105,7 @@ public HyperContext(HttpMethod method, Uri route, Version version, HyperHeaderCo } /// - public ValueTask RespondAsync(HyperStatus status, CancellationToken cancellationToken = default) => RespondAsync(status, HyperSerializers.JsonAsync, cancellationToken); + public ValueTask RespondAsync(HyperStatus status, CancellationToken cancellationToken = default) => RespondAsync(status, status.Serializer, cancellationToken); /// /// Responds to the request with the specified status in plain text. diff --git a/src/HyperSharp/Protocol/HyperHeaderCollection.cs b/src/HyperSharp/Protocol/HyperHeaderCollection.cs index fccb87a..ddbeda0 100644 --- a/src/HyperSharp/Protocol/HyperHeaderCollection.cs +++ b/src/HyperSharp/Protocol/HyperHeaderCollection.cs @@ -1,7 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Net.Http.Headers; using System.Text; @@ -10,6 +12,7 @@ namespace HyperSharp.Protocol /// /// Represents a collection of headers with string keys and lists of string values. /// + [DebuggerDisplay("{ToString(),nq}")] public sealed partial class HyperHeaderCollection : IList> { private readonly List> _headers; @@ -548,5 +551,19 @@ public bool TryGetValues(string key, [NotNullWhen(true)] out List? value /// public IEnumerator> GetEnumerator() => _headers.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => _headers.GetEnumerator(); + + public override string ToString() + { + StringBuilder stringBuilder = new(); + foreach (KeyValuePair header in _headers.OrderBy(x => x.Key)) + { + stringBuilder.Append(header.Key); + stringBuilder.Append(": "); + stringBuilder.Append(Encoding.ASCII.GetString(header.Value)); + stringBuilder.Append("\r\n"); + } + + return stringBuilder.ToString(); + } } } diff --git a/src/HyperSharp/Protocol/HyperHeaderName.cs b/src/HyperSharp/Protocol/HyperHeaderName.cs index c74ff7e..aba8714 100644 --- a/src/HyperSharp/Protocol/HyperHeaderName.cs +++ b/src/HyperSharp/Protocol/HyperHeaderName.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. namespace HyperSharp.Protocol { diff --git a/src/HyperSharp/Protocol/HyperSerializers/JsonAsync.cs b/src/HyperSharp/Protocol/HyperSerializers/JsonAsync.cs index fe19171..7e6f578 100644 --- a/src/HyperSharp/Protocol/HyperSerializers/JsonAsync.cs +++ b/src/HyperSharp/Protocol/HyperSerializers/JsonAsync.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Text; using System.Text.Json; using System.Threading; @@ -9,7 +10,7 @@ namespace HyperSharp.Protocol { public static partial class HyperSerializers { - private static readonly byte[] _contentTypeJsonEncodingHeader = "Content-Type: application/json; charset=utf-8\r\nContent-Length: "u8.ToArray(); + private static readonly byte[] _contentTypeJsonEncodingHeader = "Content-Type: application/json\r\nContent-Length: "u8.ToArray(); /// /// Serializes the body to the client as JSON using the method with the options. @@ -28,7 +29,7 @@ public static ValueTask JsonAsync(HyperContext context, HyperStatus status byte[] body = JsonSerializer.SerializeToUtf8Bytes(status.Body ?? new object(), context.Connection.Server.Configuration.JsonSerializerOptions); // Finish the Content-Length header - context.Connection.StreamWriter.Write(Encoding.ASCII.GetBytes(body.Length.ToString())); + context.Connection.StreamWriter.Write(Encoding.ASCII.GetBytes(body.Length.ToString(CultureInfo.InvariantCulture))); context.Connection.StreamWriter.Write(_newLine); // Write body diff --git a/src/HyperSharp/Protocol/HyperSerializers/PlainTextAsync.cs b/src/HyperSharp/Protocol/HyperSerializers/PlainTextAsync.cs index 4fdd977..fe30605 100644 --- a/src/HyperSharp/Protocol/HyperSerializers/PlainTextAsync.cs +++ b/src/HyperSharp/Protocol/HyperSerializers/PlainTextAsync.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -29,7 +30,7 @@ public static ValueTask PlainTextAsync(HyperContext context, HyperStatus s byte[] body = Encoding.UTF8.GetBytes(status.Body?.ToString() ?? ""); // Write Content-Length header - context.Connection.StreamWriter.Write(Encoding.ASCII.GetBytes(body.Length.ToString())); + context.Connection.StreamWriter.Write(Encoding.UTF8.GetBytes(body.Length.ToString(CultureInfo.InvariantCulture))); context.Connection.StreamWriter.Write(_newLine); // Write body diff --git a/src/HyperSharp/Protocol/HyperSerializers/RawAsync.cs b/src/HyperSharp/Protocol/HyperSerializers/RawAsync.cs new file mode 100644 index 0000000..0eb716e --- /dev/null +++ b/src/HyperSharp/Protocol/HyperSerializers/RawAsync.cs @@ -0,0 +1,41 @@ +using System; +using System.Globalization; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Toolkit.HighPerformance; + +namespace HyperSharp.Protocol +{ + /// + /// Holds a collection of static methods implementing for the most common of Content-Types. + /// + public static partial class HyperSerializers + { + private static readonly byte[] _contentLengthHeader = "Content-Length: "u8.ToArray(); + + /// + /// Serializes the body to the client as plain text using the method with the encoding. + /// + /// + public static ValueTask RawAsync(HyperContext context, HyperStatus status, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(context); + ArgumentNullException.ThrowIfNull(status); + + byte[] body = status.Body as byte[] ?? Encoding.UTF8.GetBytes(status.Body?.ToString() ?? ""); + int bodyLength = body.Length; + + // Write Content-Length header + context.Connection.StreamWriter.Write(_contentLengthHeader); + context.Connection.StreamWriter.Write(Encoding.UTF8.GetBytes(bodyLength.ToString(CultureInfo.InvariantCulture))); + context.Connection.StreamWriter.Write(_newLine); + + // Write body + context.Connection.StreamWriter.Write(_newLine); + context.Connection.StreamWriter.Write(body); + + return ValueTask.FromResult(true); + } + } +} diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Accepted.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Accepted.cs index 5d7c70a..6795448 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Accepted.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Accepted.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Accepted() => new(global::System.Net.HttpStatusCode.Accepted, new HyperHeaderCollection(), null); + public static HyperStatus Accepted() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Accepted + }; /// /// The body of the response. - public static HyperStatus Accepted(object? body) => new(global::System.Net.HttpStatusCode.Accepted, new HyperHeaderCollection(), body); + public static HyperStatus Accepted(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Accepted, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Accepted(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Accepted, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Accepted(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Accepted, headers, null); + public static HyperStatus Accepted(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Accepted, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Accepted(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Accepted, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Accepted(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Accepted, headers, body); + public static HyperStatus Accepted(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Accepted, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.AlreadyReported.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.AlreadyReported.cs index 7f4041f..3328247 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.AlreadyReported.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.AlreadyReported.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus AlreadyReported() => new(global::System.Net.HttpStatusCode.AlreadyReported, new HyperHeaderCollection(), null); + public static HyperStatus AlreadyReported() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.AlreadyReported + }; /// /// The body of the response. - public static HyperStatus AlreadyReported(object? body) => new(global::System.Net.HttpStatusCode.AlreadyReported, new HyperHeaderCollection(), body); + public static HyperStatus AlreadyReported(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.AlreadyReported, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus AlreadyReported(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.AlreadyReported, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus AlreadyReported(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.AlreadyReported, headers, null); + public static HyperStatus AlreadyReported(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.AlreadyReported, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus AlreadyReported(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.AlreadyReported, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus AlreadyReported(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.AlreadyReported, headers, body); + public static HyperStatus AlreadyReported(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.AlreadyReported, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Ambiguous.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Ambiguous.cs index 8612b43..363f081 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Ambiguous.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Ambiguous.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Ambiguous() => new(global::System.Net.HttpStatusCode.Ambiguous, new HyperHeaderCollection(), null); + public static HyperStatus Ambiguous() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Ambiguous + }; /// /// The body of the response. - public static HyperStatus Ambiguous(object? body) => new(global::System.Net.HttpStatusCode.Ambiguous, new HyperHeaderCollection(), body); + public static HyperStatus Ambiguous(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Ambiguous, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Ambiguous(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Ambiguous, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Ambiguous(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Ambiguous, headers, null); + public static HyperStatus Ambiguous(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Ambiguous, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Ambiguous(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Ambiguous, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Ambiguous(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Ambiguous, headers, body); + public static HyperStatus Ambiguous(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Ambiguous, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadGateway.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadGateway.cs index ca4f9a8..fee4478 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadGateway.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadGateway.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus BadGateway() => new(global::System.Net.HttpStatusCode.BadGateway, new HyperHeaderCollection(), null); + public static HyperStatus BadGateway() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadGateway + }; /// /// The body of the response. - public static HyperStatus BadGateway(object? body) => new(global::System.Net.HttpStatusCode.BadGateway, new HyperHeaderCollection(), body); + public static HyperStatus BadGateway(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadGateway, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus BadGateway(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadGateway, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus BadGateway(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.BadGateway, headers, null); + public static HyperStatus BadGateway(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadGateway, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus BadGateway(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadGateway, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus BadGateway(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.BadGateway, headers, body); + public static HyperStatus BadGateway(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadGateway, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadRequest.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadRequest.cs index fabd87b..690ec81 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadRequest.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.BadRequest.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus BadRequest() => new(global::System.Net.HttpStatusCode.BadRequest, new HyperHeaderCollection(), null); + public static HyperStatus BadRequest() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadRequest + }; /// /// The body of the response. - public static HyperStatus BadRequest(object? body) => new(global::System.Net.HttpStatusCode.BadRequest, new HyperHeaderCollection(), body); + public static HyperStatus BadRequest(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadRequest, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus BadRequest(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadRequest, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus BadRequest(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.BadRequest, headers, null); + public static HyperStatus BadRequest(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadRequest, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus BadRequest(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadRequest, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus BadRequest(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.BadRequest, headers, body); + public static HyperStatus BadRequest(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.BadRequest, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Conflict.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Conflict.cs index 3232a64..2cbcb78 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Conflict.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Conflict.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Conflict() => new(global::System.Net.HttpStatusCode.Conflict, new HyperHeaderCollection(), null); + public static HyperStatus Conflict() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Conflict + }; /// /// The body of the response. - public static HyperStatus Conflict(object? body) => new(global::System.Net.HttpStatusCode.Conflict, new HyperHeaderCollection(), body); + public static HyperStatus Conflict(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Conflict, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Conflict(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Conflict, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Conflict(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Conflict, headers, null); + public static HyperStatus Conflict(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Conflict, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Conflict(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Conflict, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Conflict(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Conflict, headers, body); + public static HyperStatus Conflict(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Conflict, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Continue.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Continue.cs index 643ea61..25d253d 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Continue.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Continue.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Continue() => new(global::System.Net.HttpStatusCode.Continue, new HyperHeaderCollection(), null); + public static HyperStatus Continue() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Continue + }; /// /// The body of the response. - public static HyperStatus Continue(object? body) => new(global::System.Net.HttpStatusCode.Continue, new HyperHeaderCollection(), body); + public static HyperStatus Continue(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Continue, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Continue(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Continue, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Continue(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Continue, headers, null); + public static HyperStatus Continue(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Continue, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Continue(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Continue, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Continue(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Continue, headers, body); + public static HyperStatus Continue(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Continue, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Created.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Created.cs index 24ddbac..217d64f 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Created.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Created.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Created() => new(global::System.Net.HttpStatusCode.Created, new HyperHeaderCollection(), null); + public static HyperStatus Created() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Created + }; /// /// The body of the response. - public static HyperStatus Created(object? body) => new(global::System.Net.HttpStatusCode.Created, new HyperHeaderCollection(), body); + public static HyperStatus Created(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Created, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Created(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Created, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Created(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Created, headers, null); + public static HyperStatus Created(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Created, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Created(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Created, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Created(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Created, headers, body); + public static HyperStatus Created(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Created, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.EarlyHints.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.EarlyHints.cs index bdea3ca..6b41eab 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.EarlyHints.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.EarlyHints.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus EarlyHints() => new(global::System.Net.HttpStatusCode.EarlyHints, new HyperHeaderCollection(), null); + public static HyperStatus EarlyHints() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.EarlyHints + }; /// /// The body of the response. - public static HyperStatus EarlyHints(object? body) => new(global::System.Net.HttpStatusCode.EarlyHints, new HyperHeaderCollection(), body); + public static HyperStatus EarlyHints(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.EarlyHints, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus EarlyHints(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.EarlyHints, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus EarlyHints(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.EarlyHints, headers, null); + public static HyperStatus EarlyHints(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.EarlyHints, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus EarlyHints(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.EarlyHints, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus EarlyHints(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.EarlyHints, headers, body); + public static HyperStatus EarlyHints(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.EarlyHints, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ExpectationFailed.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ExpectationFailed.cs index 4e1c66e..d8d801b 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ExpectationFailed.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ExpectationFailed.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus ExpectationFailed() => new(global::System.Net.HttpStatusCode.ExpectationFailed, new HyperHeaderCollection(), null); + public static HyperStatus ExpectationFailed() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ExpectationFailed + }; /// /// The body of the response. - public static HyperStatus ExpectationFailed(object? body) => new(global::System.Net.HttpStatusCode.ExpectationFailed, new HyperHeaderCollection(), body); + public static HyperStatus ExpectationFailed(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ExpectationFailed, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus ExpectationFailed(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ExpectationFailed, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus ExpectationFailed(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.ExpectationFailed, headers, null); + public static HyperStatus ExpectationFailed(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ExpectationFailed, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus ExpectationFailed(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ExpectationFailed, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus ExpectationFailed(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.ExpectationFailed, headers, body); + public static HyperStatus ExpectationFailed(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ExpectationFailed, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.FailedDependency.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.FailedDependency.cs index baa73f5..5e823b1 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.FailedDependency.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.FailedDependency.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus FailedDependency() => new(global::System.Net.HttpStatusCode.FailedDependency, new HyperHeaderCollection(), null); + public static HyperStatus FailedDependency() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.FailedDependency + }; /// /// The body of the response. - public static HyperStatus FailedDependency(object? body) => new(global::System.Net.HttpStatusCode.FailedDependency, new HyperHeaderCollection(), body); + public static HyperStatus FailedDependency(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.FailedDependency, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus FailedDependency(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.FailedDependency, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus FailedDependency(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.FailedDependency, headers, null); + public static HyperStatus FailedDependency(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.FailedDependency, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus FailedDependency(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.FailedDependency, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus FailedDependency(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.FailedDependency, headers, body); + public static HyperStatus FailedDependency(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.FailedDependency, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Forbidden.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Forbidden.cs index 5f06293..f602cef 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Forbidden.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Forbidden.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Forbidden() => new(global::System.Net.HttpStatusCode.Forbidden, new HyperHeaderCollection(), null); + public static HyperStatus Forbidden() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Forbidden + }; /// /// The body of the response. - public static HyperStatus Forbidden(object? body) => new(global::System.Net.HttpStatusCode.Forbidden, new HyperHeaderCollection(), body); + public static HyperStatus Forbidden(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Forbidden, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Forbidden(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Forbidden, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Forbidden(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Forbidden, headers, null); + public static HyperStatus Forbidden(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Forbidden, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Forbidden(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Forbidden, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Forbidden(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Forbidden, headers, body); + public static HyperStatus Forbidden(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Forbidden, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Found.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Found.cs index d51ce1a..9b3f4d0 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Found.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Found.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Found() => new(global::System.Net.HttpStatusCode.Found, new HyperHeaderCollection(), null); + public static HyperStatus Found() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Found + }; /// /// The body of the response. - public static HyperStatus Found(object? body) => new(global::System.Net.HttpStatusCode.Found, new HyperHeaderCollection(), body); + public static HyperStatus Found(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Found, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Found(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Found, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Found(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Found, headers, null); + public static HyperStatus Found(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Found, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Found(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Found, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Found(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Found, headers, body); + public static HyperStatus Found(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Found, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.GatewayTimeout.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.GatewayTimeout.cs index b71f980..ede7514 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.GatewayTimeout.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.GatewayTimeout.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus GatewayTimeout() => new(global::System.Net.HttpStatusCode.GatewayTimeout, new HyperHeaderCollection(), null); + public static HyperStatus GatewayTimeout() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.GatewayTimeout + }; /// /// The body of the response. - public static HyperStatus GatewayTimeout(object? body) => new(global::System.Net.HttpStatusCode.GatewayTimeout, new HyperHeaderCollection(), body); + public static HyperStatus GatewayTimeout(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.GatewayTimeout, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus GatewayTimeout(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.GatewayTimeout, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus GatewayTimeout(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.GatewayTimeout, headers, null); + public static HyperStatus GatewayTimeout(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.GatewayTimeout, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus GatewayTimeout(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.GatewayTimeout, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus GatewayTimeout(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.GatewayTimeout, headers, body); + public static HyperStatus GatewayTimeout(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.GatewayTimeout, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Gone.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Gone.cs index 2ae9a48..2fd0ca6 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Gone.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Gone.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Gone() => new(global::System.Net.HttpStatusCode.Gone, new HyperHeaderCollection(), null); + public static HyperStatus Gone() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Gone + }; /// /// The body of the response. - public static HyperStatus Gone(object? body) => new(global::System.Net.HttpStatusCode.Gone, new HyperHeaderCollection(), body); + public static HyperStatus Gone(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Gone, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Gone(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Gone, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Gone(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Gone, headers, null); + public static HyperStatus Gone(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Gone, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Gone(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Gone, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Gone(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Gone, headers, body); + public static HyperStatus Gone(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Gone, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.HttpVersionNotSupported.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.HttpVersionNotSupported.cs index 91b9569..b0c4b55 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.HttpVersionNotSupported.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.HttpVersionNotSupported.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus HttpVersionNotSupported() => new(global::System.Net.HttpStatusCode.HttpVersionNotSupported, new HyperHeaderCollection(), null); + public static HyperStatus HttpVersionNotSupported() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.HttpVersionNotSupported + }; /// /// The body of the response. - public static HyperStatus HttpVersionNotSupported(object? body) => new(global::System.Net.HttpStatusCode.HttpVersionNotSupported, new HyperHeaderCollection(), body); + public static HyperStatus HttpVersionNotSupported(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.HttpVersionNotSupported, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus HttpVersionNotSupported(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.HttpVersionNotSupported, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus HttpVersionNotSupported(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.HttpVersionNotSupported, headers, null); + public static HyperStatus HttpVersionNotSupported(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.HttpVersionNotSupported, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus HttpVersionNotSupported(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.HttpVersionNotSupported, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus HttpVersionNotSupported(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.HttpVersionNotSupported, headers, body); + public static HyperStatus HttpVersionNotSupported(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.HttpVersionNotSupported, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.IMUsed.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.IMUsed.cs index 0b6ecbd..6805a4a 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.IMUsed.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.IMUsed.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus IMUsed() => new(global::System.Net.HttpStatusCode.IMUsed, new HyperHeaderCollection(), null); + public static HyperStatus IMUsed() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.IMUsed + }; /// /// The body of the response. - public static HyperStatus IMUsed(object? body) => new(global::System.Net.HttpStatusCode.IMUsed, new HyperHeaderCollection(), body); + public static HyperStatus IMUsed(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.IMUsed, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus IMUsed(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.IMUsed, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus IMUsed(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.IMUsed, headers, null); + public static HyperStatus IMUsed(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.IMUsed, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus IMUsed(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.IMUsed, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus IMUsed(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.IMUsed, headers, body); + public static HyperStatus IMUsed(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.IMUsed, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InsufficientStorage.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InsufficientStorage.cs index 5b25ddc..a468a29 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InsufficientStorage.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InsufficientStorage.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus InsufficientStorage() => new(global::System.Net.HttpStatusCode.InsufficientStorage, new HyperHeaderCollection(), null); + public static HyperStatus InsufficientStorage() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InsufficientStorage + }; /// /// The body of the response. - public static HyperStatus InsufficientStorage(object? body) => new(global::System.Net.HttpStatusCode.InsufficientStorage, new HyperHeaderCollection(), body); + public static HyperStatus InsufficientStorage(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InsufficientStorage, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus InsufficientStorage(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InsufficientStorage, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus InsufficientStorage(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.InsufficientStorage, headers, null); + public static HyperStatus InsufficientStorage(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InsufficientStorage, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus InsufficientStorage(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InsufficientStorage, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus InsufficientStorage(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.InsufficientStorage, headers, body); + public static HyperStatus InsufficientStorage(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InsufficientStorage, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InternalServerError.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InternalServerError.cs index 2177e1e..79917ad 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InternalServerError.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.InternalServerError.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus InternalServerError() => new(global::System.Net.HttpStatusCode.InternalServerError, new HyperHeaderCollection(), null); + public static HyperStatus InternalServerError() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InternalServerError + }; /// /// The body of the response. - public static HyperStatus InternalServerError(object? body) => new(global::System.Net.HttpStatusCode.InternalServerError, new HyperHeaderCollection(), body); + public static HyperStatus InternalServerError(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InternalServerError, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus InternalServerError(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InternalServerError, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus InternalServerError(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.InternalServerError, headers, null); + public static HyperStatus InternalServerError(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InternalServerError, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus InternalServerError(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InternalServerError, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus InternalServerError(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.InternalServerError, headers, body); + public static HyperStatus InternalServerError(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.InternalServerError, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LengthRequired.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LengthRequired.cs index 7355656..0790e5f 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LengthRequired.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LengthRequired.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus LengthRequired() => new(global::System.Net.HttpStatusCode.LengthRequired, new HyperHeaderCollection(), null); + public static HyperStatus LengthRequired() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LengthRequired + }; /// /// The body of the response. - public static HyperStatus LengthRequired(object? body) => new(global::System.Net.HttpStatusCode.LengthRequired, new HyperHeaderCollection(), body); + public static HyperStatus LengthRequired(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LengthRequired, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus LengthRequired(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LengthRequired, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus LengthRequired(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.LengthRequired, headers, null); + public static HyperStatus LengthRequired(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LengthRequired, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus LengthRequired(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LengthRequired, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus LengthRequired(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.LengthRequired, headers, body); + public static HyperStatus LengthRequired(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LengthRequired, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Locked.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Locked.cs index a3922f0..1668d9e 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Locked.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Locked.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Locked() => new(global::System.Net.HttpStatusCode.Locked, new HyperHeaderCollection(), null); + public static HyperStatus Locked() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Locked + }; /// /// The body of the response. - public static HyperStatus Locked(object? body) => new(global::System.Net.HttpStatusCode.Locked, new HyperHeaderCollection(), body); + public static HyperStatus Locked(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Locked, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Locked(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Locked, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Locked(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Locked, headers, null); + public static HyperStatus Locked(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Locked, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Locked(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Locked, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Locked(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Locked, headers, body); + public static HyperStatus Locked(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Locked, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LoopDetected.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LoopDetected.cs index e6b7c7e..972ef61 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LoopDetected.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.LoopDetected.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus LoopDetected() => new(global::System.Net.HttpStatusCode.LoopDetected, new HyperHeaderCollection(), null); + public static HyperStatus LoopDetected() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LoopDetected + }; /// /// The body of the response. - public static HyperStatus LoopDetected(object? body) => new(global::System.Net.HttpStatusCode.LoopDetected, new HyperHeaderCollection(), body); + public static HyperStatus LoopDetected(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LoopDetected, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus LoopDetected(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LoopDetected, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus LoopDetected(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.LoopDetected, headers, null); + public static HyperStatus LoopDetected(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LoopDetected, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus LoopDetected(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LoopDetected, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus LoopDetected(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.LoopDetected, headers, body); + public static HyperStatus LoopDetected(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.LoopDetected, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MethodNotAllowed.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MethodNotAllowed.cs index 1cd6fe8..c58ca51 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MethodNotAllowed.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MethodNotAllowed.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus MethodNotAllowed() => new(global::System.Net.HttpStatusCode.MethodNotAllowed, new HyperHeaderCollection(), null); + public static HyperStatus MethodNotAllowed() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MethodNotAllowed + }; /// /// The body of the response. - public static HyperStatus MethodNotAllowed(object? body) => new(global::System.Net.HttpStatusCode.MethodNotAllowed, new HyperHeaderCollection(), body); + public static HyperStatus MethodNotAllowed(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MethodNotAllowed, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus MethodNotAllowed(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MethodNotAllowed, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus MethodNotAllowed(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.MethodNotAllowed, headers, null); + public static HyperStatus MethodNotAllowed(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MethodNotAllowed, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus MethodNotAllowed(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MethodNotAllowed, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus MethodNotAllowed(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.MethodNotAllowed, headers, body); + public static HyperStatus MethodNotAllowed(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MethodNotAllowed, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MisdirectedRequest.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MisdirectedRequest.cs index 0f269bd..7cd8ca4 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MisdirectedRequest.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MisdirectedRequest.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus MisdirectedRequest() => new(global::System.Net.HttpStatusCode.MisdirectedRequest, new HyperHeaderCollection(), null); + public static HyperStatus MisdirectedRequest() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MisdirectedRequest + }; /// /// The body of the response. - public static HyperStatus MisdirectedRequest(object? body) => new(global::System.Net.HttpStatusCode.MisdirectedRequest, new HyperHeaderCollection(), body); + public static HyperStatus MisdirectedRequest(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MisdirectedRequest, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus MisdirectedRequest(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MisdirectedRequest, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus MisdirectedRequest(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.MisdirectedRequest, headers, null); + public static HyperStatus MisdirectedRequest(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MisdirectedRequest, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus MisdirectedRequest(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MisdirectedRequest, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus MisdirectedRequest(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.MisdirectedRequest, headers, body); + public static HyperStatus MisdirectedRequest(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MisdirectedRequest, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Moved.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Moved.cs index 2d3e45d..272a754 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Moved.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Moved.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Moved() => new(global::System.Net.HttpStatusCode.Moved, new HyperHeaderCollection(), null); + public static HyperStatus Moved() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Moved + }; /// /// The body of the response. - public static HyperStatus Moved(object? body) => new(global::System.Net.HttpStatusCode.Moved, new HyperHeaderCollection(), body); + public static HyperStatus Moved(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Moved, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Moved(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Moved, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Moved(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Moved, headers, null); + public static HyperStatus Moved(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Moved, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Moved(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Moved, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Moved(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Moved, headers, body); + public static HyperStatus Moved(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Moved, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MovedPermanently.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MovedPermanently.cs index d38d492..cedf478 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MovedPermanently.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MovedPermanently.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus MovedPermanently() => new(global::System.Net.HttpStatusCode.MovedPermanently, new HyperHeaderCollection(), null); + public static HyperStatus MovedPermanently() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MovedPermanently + }; /// /// The body of the response. - public static HyperStatus MovedPermanently(object? body) => new(global::System.Net.HttpStatusCode.MovedPermanently, new HyperHeaderCollection(), body); + public static HyperStatus MovedPermanently(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MovedPermanently, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus MovedPermanently(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MovedPermanently, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus MovedPermanently(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.MovedPermanently, headers, null); + public static HyperStatus MovedPermanently(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MovedPermanently, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus MovedPermanently(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MovedPermanently, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus MovedPermanently(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.MovedPermanently, headers, body); + public static HyperStatus MovedPermanently(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MovedPermanently, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultiStatus.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultiStatus.cs index f7b3625..a3fd56d 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultiStatus.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultiStatus.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus MultiStatus() => new(global::System.Net.HttpStatusCode.MultiStatus, new HyperHeaderCollection(), null); + public static HyperStatus MultiStatus() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultiStatus + }; /// /// The body of the response. - public static HyperStatus MultiStatus(object? body) => new(global::System.Net.HttpStatusCode.MultiStatus, new HyperHeaderCollection(), body); + public static HyperStatus MultiStatus(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultiStatus, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus MultiStatus(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultiStatus, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus MultiStatus(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.MultiStatus, headers, null); + public static HyperStatus MultiStatus(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultiStatus, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus MultiStatus(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultiStatus, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus MultiStatus(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.MultiStatus, headers, body); + public static HyperStatus MultiStatus(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultiStatus, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultipleChoices.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultipleChoices.cs index 544dcb5..011273e 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultipleChoices.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.MultipleChoices.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus MultipleChoices() => new(global::System.Net.HttpStatusCode.MultipleChoices, new HyperHeaderCollection(), null); + public static HyperStatus MultipleChoices() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultipleChoices + }; /// /// The body of the response. - public static HyperStatus MultipleChoices(object? body) => new(global::System.Net.HttpStatusCode.MultipleChoices, new HyperHeaderCollection(), body); + public static HyperStatus MultipleChoices(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultipleChoices, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus MultipleChoices(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultipleChoices, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus MultipleChoices(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.MultipleChoices, headers, null); + public static HyperStatus MultipleChoices(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultipleChoices, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus MultipleChoices(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultipleChoices, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus MultipleChoices(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.MultipleChoices, headers, body); + public static HyperStatus MultipleChoices(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.MultipleChoices, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NetworkAuthenticationRequired.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NetworkAuthenticationRequired.cs index 2a71fda..f01fa4d 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NetworkAuthenticationRequired.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NetworkAuthenticationRequired.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NetworkAuthenticationRequired() => new(global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, new HyperHeaderCollection(), null); + public static HyperStatus NetworkAuthenticationRequired() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NetworkAuthenticationRequired + }; /// /// The body of the response. - public static HyperStatus NetworkAuthenticationRequired(object? body) => new(global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, new HyperHeaderCollection(), body); + public static HyperStatus NetworkAuthenticationRequired(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NetworkAuthenticationRequired(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NetworkAuthenticationRequired(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, headers, null); + public static HyperStatus NetworkAuthenticationRequired(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NetworkAuthenticationRequired(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NetworkAuthenticationRequired(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, headers, body); + public static HyperStatus NetworkAuthenticationRequired(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NetworkAuthenticationRequired, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NoContent.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NoContent.cs index 3b3dd1f..ae140d0 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NoContent.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NoContent.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NoContent() => new(global::System.Net.HttpStatusCode.NoContent, new HyperHeaderCollection(), null); + public static HyperStatus NoContent() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NoContent + }; /// /// The body of the response. - public static HyperStatus NoContent(object? body) => new(global::System.Net.HttpStatusCode.NoContent, new HyperHeaderCollection(), body); + public static HyperStatus NoContent(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NoContent, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NoContent(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NoContent, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NoContent(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NoContent, headers, null); + public static HyperStatus NoContent(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NoContent, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NoContent(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NoContent, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NoContent(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NoContent, headers, body); + public static HyperStatus NoContent(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NoContent, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NonAuthoritativeInformation.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NonAuthoritativeInformation.cs index bdecf21..a2d1400 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NonAuthoritativeInformation.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NonAuthoritativeInformation.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NonAuthoritativeInformation() => new(global::System.Net.HttpStatusCode.NonAuthoritativeInformation, new HyperHeaderCollection(), null); + public static HyperStatus NonAuthoritativeInformation() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NonAuthoritativeInformation + }; /// /// The body of the response. - public static HyperStatus NonAuthoritativeInformation(object? body) => new(global::System.Net.HttpStatusCode.NonAuthoritativeInformation, new HyperHeaderCollection(), body); + public static HyperStatus NonAuthoritativeInformation(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NonAuthoritativeInformation, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NonAuthoritativeInformation(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NonAuthoritativeInformation, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NonAuthoritativeInformation(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NonAuthoritativeInformation, headers, null); + public static HyperStatus NonAuthoritativeInformation(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NonAuthoritativeInformation, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NonAuthoritativeInformation(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NonAuthoritativeInformation, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NonAuthoritativeInformation(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NonAuthoritativeInformation, headers, body); + public static HyperStatus NonAuthoritativeInformation(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NonAuthoritativeInformation, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotAcceptable.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotAcceptable.cs index 0f59ee9..d8ac08d 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotAcceptable.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotAcceptable.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NotAcceptable() => new(global::System.Net.HttpStatusCode.NotAcceptable, new HyperHeaderCollection(), null); + public static HyperStatus NotAcceptable() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotAcceptable + }; /// /// The body of the response. - public static HyperStatus NotAcceptable(object? body) => new(global::System.Net.HttpStatusCode.NotAcceptable, new HyperHeaderCollection(), body); + public static HyperStatus NotAcceptable(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotAcceptable, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NotAcceptable(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotAcceptable, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NotAcceptable(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NotAcceptable, headers, null); + public static HyperStatus NotAcceptable(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotAcceptable, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NotAcceptable(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotAcceptable, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NotAcceptable(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NotAcceptable, headers, body); + public static HyperStatus NotAcceptable(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotAcceptable, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotExtended.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotExtended.cs index 9e4c4fa..2fcbd77 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotExtended.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotExtended.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NotExtended() => new(global::System.Net.HttpStatusCode.NotExtended, new HyperHeaderCollection(), null); + public static HyperStatus NotExtended() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotExtended + }; /// /// The body of the response. - public static HyperStatus NotExtended(object? body) => new(global::System.Net.HttpStatusCode.NotExtended, new HyperHeaderCollection(), body); + public static HyperStatus NotExtended(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotExtended, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NotExtended(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotExtended, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NotExtended(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NotExtended, headers, null); + public static HyperStatus NotExtended(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotExtended, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NotExtended(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotExtended, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NotExtended(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NotExtended, headers, body); + public static HyperStatus NotExtended(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotExtended, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotFound.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotFound.cs index 2709278..2e40a12 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotFound.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotFound.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NotFound() => new(global::System.Net.HttpStatusCode.NotFound, new HyperHeaderCollection(), null); + public static HyperStatus NotFound() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotFound + }; /// /// The body of the response. - public static HyperStatus NotFound(object? body) => new(global::System.Net.HttpStatusCode.NotFound, new HyperHeaderCollection(), body); + public static HyperStatus NotFound(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotFound, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NotFound(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotFound, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NotFound(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NotFound, headers, null); + public static HyperStatus NotFound(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotFound, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NotFound(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotFound, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NotFound(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NotFound, headers, body); + public static HyperStatus NotFound(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotFound, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotImplemented.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotImplemented.cs index 3de6e7b..8b70544 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotImplemented.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotImplemented.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NotImplemented() => new(global::System.Net.HttpStatusCode.NotImplemented, new HyperHeaderCollection(), null); + public static HyperStatus NotImplemented() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotImplemented + }; /// /// The body of the response. - public static HyperStatus NotImplemented(object? body) => new(global::System.Net.HttpStatusCode.NotImplemented, new HyperHeaderCollection(), body); + public static HyperStatus NotImplemented(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotImplemented, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NotImplemented(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotImplemented, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NotImplemented(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NotImplemented, headers, null); + public static HyperStatus NotImplemented(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotImplemented, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NotImplemented(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotImplemented, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NotImplemented(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NotImplemented, headers, body); + public static HyperStatus NotImplemented(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotImplemented, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotModified.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotModified.cs index dfafd8f..1c6c07e 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotModified.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.NotModified.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus NotModified() => new(global::System.Net.HttpStatusCode.NotModified, new HyperHeaderCollection(), null); + public static HyperStatus NotModified() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotModified + }; /// /// The body of the response. - public static HyperStatus NotModified(object? body) => new(global::System.Net.HttpStatusCode.NotModified, new HyperHeaderCollection(), body); + public static HyperStatus NotModified(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotModified, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus NotModified(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotModified, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus NotModified(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.NotModified, headers, null); + public static HyperStatus NotModified(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotModified, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus NotModified(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotModified, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus NotModified(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.NotModified, headers, body); + public static HyperStatus NotModified(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.NotModified, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.OK.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.OK.cs index a267817..fdf9d76 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.OK.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.OK.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus OK() => new(global::System.Net.HttpStatusCode.OK, new HyperHeaderCollection(), null); + public static HyperStatus OK() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.OK + }; /// /// The body of the response. - public static HyperStatus OK(object? body) => new(global::System.Net.HttpStatusCode.OK, new HyperHeaderCollection(), body); + public static HyperStatus OK(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.OK, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus OK(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.OK, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus OK(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.OK, headers, null); + public static HyperStatus OK(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.OK, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus OK(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.OK, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus OK(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.OK, headers, body); + public static HyperStatus OK(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.OK, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PartialContent.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PartialContent.cs index 685a8b4..363c7c4 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PartialContent.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PartialContent.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus PartialContent() => new(global::System.Net.HttpStatusCode.PartialContent, new HyperHeaderCollection(), null); + public static HyperStatus PartialContent() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PartialContent + }; /// /// The body of the response. - public static HyperStatus PartialContent(object? body) => new(global::System.Net.HttpStatusCode.PartialContent, new HyperHeaderCollection(), body); + public static HyperStatus PartialContent(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PartialContent, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus PartialContent(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PartialContent, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus PartialContent(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.PartialContent, headers, null); + public static HyperStatus PartialContent(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PartialContent, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus PartialContent(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PartialContent, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus PartialContent(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.PartialContent, headers, body); + public static HyperStatus PartialContent(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PartialContent, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PaymentRequired.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PaymentRequired.cs index 94bf474..504f654 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PaymentRequired.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PaymentRequired.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus PaymentRequired() => new(global::System.Net.HttpStatusCode.PaymentRequired, new HyperHeaderCollection(), null); + public static HyperStatus PaymentRequired() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PaymentRequired + }; /// /// The body of the response. - public static HyperStatus PaymentRequired(object? body) => new(global::System.Net.HttpStatusCode.PaymentRequired, new HyperHeaderCollection(), body); + public static HyperStatus PaymentRequired(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PaymentRequired, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus PaymentRequired(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PaymentRequired, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus PaymentRequired(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.PaymentRequired, headers, null); + public static HyperStatus PaymentRequired(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PaymentRequired, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus PaymentRequired(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PaymentRequired, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus PaymentRequired(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.PaymentRequired, headers, body); + public static HyperStatus PaymentRequired(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PaymentRequired, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PermanentRedirect.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PermanentRedirect.cs index 9a4598c..edfaec5 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PermanentRedirect.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PermanentRedirect.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus PermanentRedirect() => new(global::System.Net.HttpStatusCode.PermanentRedirect, new HyperHeaderCollection(), null); + public static HyperStatus PermanentRedirect() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PermanentRedirect + }; /// /// The body of the response. - public static HyperStatus PermanentRedirect(object? body) => new(global::System.Net.HttpStatusCode.PermanentRedirect, new HyperHeaderCollection(), body); + public static HyperStatus PermanentRedirect(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PermanentRedirect, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus PermanentRedirect(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PermanentRedirect, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus PermanentRedirect(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.PermanentRedirect, headers, null); + public static HyperStatus PermanentRedirect(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PermanentRedirect, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus PermanentRedirect(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PermanentRedirect, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus PermanentRedirect(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.PermanentRedirect, headers, body); + public static HyperStatus PermanentRedirect(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PermanentRedirect, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionFailed.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionFailed.cs index 656ab82..7d05a34 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionFailed.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionFailed.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus PreconditionFailed() => new(global::System.Net.HttpStatusCode.PreconditionFailed, new HyperHeaderCollection(), null); + public static HyperStatus PreconditionFailed() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionFailed + }; /// /// The body of the response. - public static HyperStatus PreconditionFailed(object? body) => new(global::System.Net.HttpStatusCode.PreconditionFailed, new HyperHeaderCollection(), body); + public static HyperStatus PreconditionFailed(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionFailed, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus PreconditionFailed(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionFailed, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus PreconditionFailed(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.PreconditionFailed, headers, null); + public static HyperStatus PreconditionFailed(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionFailed, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus PreconditionFailed(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionFailed, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus PreconditionFailed(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.PreconditionFailed, headers, body); + public static HyperStatus PreconditionFailed(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionFailed, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionRequired.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionRequired.cs index ba64cf1..6470074 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionRequired.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.PreconditionRequired.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus PreconditionRequired() => new(global::System.Net.HttpStatusCode.PreconditionRequired, new HyperHeaderCollection(), null); + public static HyperStatus PreconditionRequired() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionRequired + }; /// /// The body of the response. - public static HyperStatus PreconditionRequired(object? body) => new(global::System.Net.HttpStatusCode.PreconditionRequired, new HyperHeaderCollection(), body); + public static HyperStatus PreconditionRequired(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionRequired, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus PreconditionRequired(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionRequired, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus PreconditionRequired(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.PreconditionRequired, headers, null); + public static HyperStatus PreconditionRequired(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionRequired, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus PreconditionRequired(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionRequired, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus PreconditionRequired(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.PreconditionRequired, headers, body); + public static HyperStatus PreconditionRequired(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.PreconditionRequired, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Processing.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Processing.cs index 6ff6f3e..104e927 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Processing.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Processing.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Processing() => new(global::System.Net.HttpStatusCode.Processing, new HyperHeaderCollection(), null); + public static HyperStatus Processing() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Processing + }; /// /// The body of the response. - public static HyperStatus Processing(object? body) => new(global::System.Net.HttpStatusCode.Processing, new HyperHeaderCollection(), body); + public static HyperStatus Processing(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Processing, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Processing(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Processing, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Processing(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Processing, headers, null); + public static HyperStatus Processing(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Processing, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Processing(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Processing, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Processing(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Processing, headers, body); + public static HyperStatus Processing(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Processing, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ProxyAuthenticationRequired.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ProxyAuthenticationRequired.cs index fda474a..fb05bdd 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ProxyAuthenticationRequired.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ProxyAuthenticationRequired.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus ProxyAuthenticationRequired() => new(global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, new HyperHeaderCollection(), null); + public static HyperStatus ProxyAuthenticationRequired() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ProxyAuthenticationRequired + }; /// /// The body of the response. - public static HyperStatus ProxyAuthenticationRequired(object? body) => new(global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, new HyperHeaderCollection(), body); + public static HyperStatus ProxyAuthenticationRequired(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus ProxyAuthenticationRequired(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus ProxyAuthenticationRequired(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, headers, null); + public static HyperStatus ProxyAuthenticationRequired(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus ProxyAuthenticationRequired(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus ProxyAuthenticationRequired(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, headers, body); + public static HyperStatus ProxyAuthenticationRequired(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ProxyAuthenticationRequired, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Redirect.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Redirect.cs index f10bd52..0d3da3f 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Redirect.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Redirect.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Redirect() => new(global::System.Net.HttpStatusCode.Redirect, new HyperHeaderCollection(), null); + public static HyperStatus Redirect() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Redirect + }; /// /// The body of the response. - public static HyperStatus Redirect(object? body) => new(global::System.Net.HttpStatusCode.Redirect, new HyperHeaderCollection(), body); + public static HyperStatus Redirect(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Redirect, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Redirect(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Redirect, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Redirect(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Redirect, headers, null); + public static HyperStatus Redirect(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Redirect, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Redirect(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Redirect, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Redirect(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Redirect, headers, body); + public static HyperStatus Redirect(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Redirect, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectKeepVerb.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectKeepVerb.cs index d284d2f..c3702c2 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectKeepVerb.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectKeepVerb.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus RedirectKeepVerb() => new(global::System.Net.HttpStatusCode.RedirectKeepVerb, new HyperHeaderCollection(), null); + public static HyperStatus RedirectKeepVerb() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectKeepVerb + }; /// /// The body of the response. - public static HyperStatus RedirectKeepVerb(object? body) => new(global::System.Net.HttpStatusCode.RedirectKeepVerb, new HyperHeaderCollection(), body); + public static HyperStatus RedirectKeepVerb(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectKeepVerb, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus RedirectKeepVerb(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectKeepVerb, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus RedirectKeepVerb(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.RedirectKeepVerb, headers, null); + public static HyperStatus RedirectKeepVerb(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectKeepVerb, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus RedirectKeepVerb(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectKeepVerb, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus RedirectKeepVerb(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.RedirectKeepVerb, headers, body); + public static HyperStatus RedirectKeepVerb(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectKeepVerb, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectMethod.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectMethod.cs index ef9894e..9d4790f 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectMethod.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RedirectMethod.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus RedirectMethod() => new(global::System.Net.HttpStatusCode.RedirectMethod, new HyperHeaderCollection(), null); + public static HyperStatus RedirectMethod() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectMethod + }; /// /// The body of the response. - public static HyperStatus RedirectMethod(object? body) => new(global::System.Net.HttpStatusCode.RedirectMethod, new HyperHeaderCollection(), body); + public static HyperStatus RedirectMethod(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectMethod, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus RedirectMethod(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectMethod, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus RedirectMethod(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.RedirectMethod, headers, null); + public static HyperStatus RedirectMethod(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectMethod, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus RedirectMethod(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectMethod, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus RedirectMethod(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.RedirectMethod, headers, body); + public static HyperStatus RedirectMethod(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RedirectMethod, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestEntityTooLarge.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestEntityTooLarge.cs index b43e9f5..bc56456 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestEntityTooLarge.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestEntityTooLarge.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus RequestEntityTooLarge() => new(global::System.Net.HttpStatusCode.RequestEntityTooLarge, new HyperHeaderCollection(), null); + public static HyperStatus RequestEntityTooLarge() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestEntityTooLarge + }; /// /// The body of the response. - public static HyperStatus RequestEntityTooLarge(object? body) => new(global::System.Net.HttpStatusCode.RequestEntityTooLarge, new HyperHeaderCollection(), body); + public static HyperStatus RequestEntityTooLarge(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestEntityTooLarge, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus RequestEntityTooLarge(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestEntityTooLarge, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus RequestEntityTooLarge(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.RequestEntityTooLarge, headers, null); + public static HyperStatus RequestEntityTooLarge(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestEntityTooLarge, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus RequestEntityTooLarge(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestEntityTooLarge, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus RequestEntityTooLarge(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.RequestEntityTooLarge, headers, body); + public static HyperStatus RequestEntityTooLarge(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestEntityTooLarge, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestHeaderFieldsTooLarge.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestHeaderFieldsTooLarge.cs index 364d84c..9869086 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestHeaderFieldsTooLarge.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestHeaderFieldsTooLarge.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus RequestHeaderFieldsTooLarge() => new(global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, new HyperHeaderCollection(), null); + public static HyperStatus RequestHeaderFieldsTooLarge() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge + }; /// /// The body of the response. - public static HyperStatus RequestHeaderFieldsTooLarge(object? body) => new(global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, new HyperHeaderCollection(), body); + public static HyperStatus RequestHeaderFieldsTooLarge(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus RequestHeaderFieldsTooLarge(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus RequestHeaderFieldsTooLarge(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, headers, null); + public static HyperStatus RequestHeaderFieldsTooLarge(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus RequestHeaderFieldsTooLarge(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus RequestHeaderFieldsTooLarge(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, headers, body); + public static HyperStatus RequestHeaderFieldsTooLarge(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestTimeout.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestTimeout.cs index 02fc8a7..ba628ac 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestTimeout.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestTimeout.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus RequestTimeout() => new(global::System.Net.HttpStatusCode.RequestTimeout, new HyperHeaderCollection(), null); + public static HyperStatus RequestTimeout() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestTimeout + }; /// /// The body of the response. - public static HyperStatus RequestTimeout(object? body) => new(global::System.Net.HttpStatusCode.RequestTimeout, new HyperHeaderCollection(), body); + public static HyperStatus RequestTimeout(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestTimeout, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus RequestTimeout(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestTimeout, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus RequestTimeout(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.RequestTimeout, headers, null); + public static HyperStatus RequestTimeout(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestTimeout, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus RequestTimeout(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestTimeout, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus RequestTimeout(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.RequestTimeout, headers, body); + public static HyperStatus RequestTimeout(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestTimeout, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestUriTooLong.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestUriTooLong.cs index 2a239c3..b469945 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestUriTooLong.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestUriTooLong.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus RequestUriTooLong() => new(global::System.Net.HttpStatusCode.RequestUriTooLong, new HyperHeaderCollection(), null); + public static HyperStatus RequestUriTooLong() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestUriTooLong + }; /// /// The body of the response. - public static HyperStatus RequestUriTooLong(object? body) => new(global::System.Net.HttpStatusCode.RequestUriTooLong, new HyperHeaderCollection(), body); + public static HyperStatus RequestUriTooLong(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestUriTooLong, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus RequestUriTooLong(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestUriTooLong, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus RequestUriTooLong(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.RequestUriTooLong, headers, null); + public static HyperStatus RequestUriTooLong(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestUriTooLong, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus RequestUriTooLong(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestUriTooLong, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus RequestUriTooLong(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.RequestUriTooLong, headers, body); + public static HyperStatus RequestUriTooLong(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestUriTooLong, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestedRangeNotSatisfiable.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestedRangeNotSatisfiable.cs index 41618aa..111ae38 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestedRangeNotSatisfiable.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.RequestedRangeNotSatisfiable.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus RequestedRangeNotSatisfiable() => new(global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, new HyperHeaderCollection(), null); + public static HyperStatus RequestedRangeNotSatisfiable() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable + }; /// /// The body of the response. - public static HyperStatus RequestedRangeNotSatisfiable(object? body) => new(global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, new HyperHeaderCollection(), body); + public static HyperStatus RequestedRangeNotSatisfiable(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus RequestedRangeNotSatisfiable(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus RequestedRangeNotSatisfiable(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, headers, null); + public static HyperStatus RequestedRangeNotSatisfiable(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus RequestedRangeNotSatisfiable(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus RequestedRangeNotSatisfiable(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, headers, body); + public static HyperStatus RequestedRangeNotSatisfiable(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.RequestedRangeNotSatisfiable, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ResetContent.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ResetContent.cs index 2bfa76d..a40fcf7 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ResetContent.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ResetContent.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus ResetContent() => new(global::System.Net.HttpStatusCode.ResetContent, new HyperHeaderCollection(), null); + public static HyperStatus ResetContent() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ResetContent + }; /// /// The body of the response. - public static HyperStatus ResetContent(object? body) => new(global::System.Net.HttpStatusCode.ResetContent, new HyperHeaderCollection(), body); + public static HyperStatus ResetContent(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ResetContent, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus ResetContent(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ResetContent, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus ResetContent(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.ResetContent, headers, null); + public static HyperStatus ResetContent(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ResetContent, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus ResetContent(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ResetContent, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus ResetContent(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.ResetContent, headers, body); + public static HyperStatus ResetContent(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ResetContent, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SeeOther.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SeeOther.cs index 98ce6b5..8e20932 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SeeOther.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SeeOther.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus SeeOther() => new(global::System.Net.HttpStatusCode.SeeOther, new HyperHeaderCollection(), null); + public static HyperStatus SeeOther() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SeeOther + }; /// /// The body of the response. - public static HyperStatus SeeOther(object? body) => new(global::System.Net.HttpStatusCode.SeeOther, new HyperHeaderCollection(), body); + public static HyperStatus SeeOther(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SeeOther, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus SeeOther(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SeeOther, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus SeeOther(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.SeeOther, headers, null); + public static HyperStatus SeeOther(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SeeOther, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus SeeOther(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SeeOther, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus SeeOther(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.SeeOther, headers, body); + public static HyperStatus SeeOther(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SeeOther, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ServiceUnavailable.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ServiceUnavailable.cs index 4c3502d..8403236 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ServiceUnavailable.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.ServiceUnavailable.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus ServiceUnavailable() => new(global::System.Net.HttpStatusCode.ServiceUnavailable, new HyperHeaderCollection(), null); + public static HyperStatus ServiceUnavailable() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ServiceUnavailable + }; /// /// The body of the response. - public static HyperStatus ServiceUnavailable(object? body) => new(global::System.Net.HttpStatusCode.ServiceUnavailable, new HyperHeaderCollection(), body); + public static HyperStatus ServiceUnavailable(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ServiceUnavailable, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus ServiceUnavailable(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ServiceUnavailable, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus ServiceUnavailable(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.ServiceUnavailable, headers, null); + public static HyperStatus ServiceUnavailable(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ServiceUnavailable, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus ServiceUnavailable(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ServiceUnavailable, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus ServiceUnavailable(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.ServiceUnavailable, headers, body); + public static HyperStatus ServiceUnavailable(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.ServiceUnavailable, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SwitchingProtocols.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SwitchingProtocols.cs index 024912b..8b3ec49 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SwitchingProtocols.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.SwitchingProtocols.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus SwitchingProtocols() => new(global::System.Net.HttpStatusCode.SwitchingProtocols, new HyperHeaderCollection(), null); + public static HyperStatus SwitchingProtocols() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SwitchingProtocols + }; /// /// The body of the response. - public static HyperStatus SwitchingProtocols(object? body) => new(global::System.Net.HttpStatusCode.SwitchingProtocols, new HyperHeaderCollection(), body); + public static HyperStatus SwitchingProtocols(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SwitchingProtocols, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus SwitchingProtocols(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SwitchingProtocols, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus SwitchingProtocols(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.SwitchingProtocols, headers, null); + public static HyperStatus SwitchingProtocols(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SwitchingProtocols, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus SwitchingProtocols(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SwitchingProtocols, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus SwitchingProtocols(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.SwitchingProtocols, headers, body); + public static HyperStatus SwitchingProtocols(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.SwitchingProtocols, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TemporaryRedirect.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TemporaryRedirect.cs index 6e47ba3..db9ce91 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TemporaryRedirect.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TemporaryRedirect.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus TemporaryRedirect() => new(global::System.Net.HttpStatusCode.TemporaryRedirect, new HyperHeaderCollection(), null); + public static HyperStatus TemporaryRedirect() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TemporaryRedirect + }; /// /// The body of the response. - public static HyperStatus TemporaryRedirect(object? body) => new(global::System.Net.HttpStatusCode.TemporaryRedirect, new HyperHeaderCollection(), body); + public static HyperStatus TemporaryRedirect(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TemporaryRedirect, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus TemporaryRedirect(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TemporaryRedirect, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus TemporaryRedirect(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.TemporaryRedirect, headers, null); + public static HyperStatus TemporaryRedirect(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TemporaryRedirect, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus TemporaryRedirect(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TemporaryRedirect, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus TemporaryRedirect(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.TemporaryRedirect, headers, body); + public static HyperStatus TemporaryRedirect(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TemporaryRedirect, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TooManyRequests.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TooManyRequests.cs index 96cf091..f798535 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TooManyRequests.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.TooManyRequests.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus TooManyRequests() => new(global::System.Net.HttpStatusCode.TooManyRequests, new HyperHeaderCollection(), null); + public static HyperStatus TooManyRequests() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TooManyRequests + }; /// /// The body of the response. - public static HyperStatus TooManyRequests(object? body) => new(global::System.Net.HttpStatusCode.TooManyRequests, new HyperHeaderCollection(), body); + public static HyperStatus TooManyRequests(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TooManyRequests, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus TooManyRequests(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TooManyRequests, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus TooManyRequests(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.TooManyRequests, headers, null); + public static HyperStatus TooManyRequests(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TooManyRequests, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus TooManyRequests(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TooManyRequests, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus TooManyRequests(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.TooManyRequests, headers, body); + public static HyperStatus TooManyRequests(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.TooManyRequests, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unauthorized.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unauthorized.cs index a75de5e..babfb6b 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unauthorized.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unauthorized.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Unauthorized() => new(global::System.Net.HttpStatusCode.Unauthorized, new HyperHeaderCollection(), null); + public static HyperStatus Unauthorized() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unauthorized + }; /// /// The body of the response. - public static HyperStatus Unauthorized(object? body) => new(global::System.Net.HttpStatusCode.Unauthorized, new HyperHeaderCollection(), body); + public static HyperStatus Unauthorized(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unauthorized, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Unauthorized(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unauthorized, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Unauthorized(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Unauthorized, headers, null); + public static HyperStatus Unauthorized(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unauthorized, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Unauthorized(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unauthorized, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Unauthorized(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Unauthorized, headers, body); + public static HyperStatus Unauthorized(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unauthorized, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnavailableForLegalReasons.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnavailableForLegalReasons.cs index d3181aa..5f74303 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnavailableForLegalReasons.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnavailableForLegalReasons.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus UnavailableForLegalReasons() => new(global::System.Net.HttpStatusCode.UnavailableForLegalReasons, new HyperHeaderCollection(), null); + public static HyperStatus UnavailableForLegalReasons() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnavailableForLegalReasons + }; /// /// The body of the response. - public static HyperStatus UnavailableForLegalReasons(object? body) => new(global::System.Net.HttpStatusCode.UnavailableForLegalReasons, new HyperHeaderCollection(), body); + public static HyperStatus UnavailableForLegalReasons(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnavailableForLegalReasons, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus UnavailableForLegalReasons(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnavailableForLegalReasons, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus UnavailableForLegalReasons(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.UnavailableForLegalReasons, headers, null); + public static HyperStatus UnavailableForLegalReasons(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnavailableForLegalReasons, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus UnavailableForLegalReasons(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnavailableForLegalReasons, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus UnavailableForLegalReasons(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.UnavailableForLegalReasons, headers, body); + public static HyperStatus UnavailableForLegalReasons(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnavailableForLegalReasons, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableContent.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableContent.cs index 8375061..8a9ba23 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableContent.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableContent.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus UnprocessableContent() => new(global::System.Net.HttpStatusCode.UnprocessableContent, new HyperHeaderCollection(), null); + public static HyperStatus UnprocessableContent() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableContent + }; /// /// The body of the response. - public static HyperStatus UnprocessableContent(object? body) => new(global::System.Net.HttpStatusCode.UnprocessableContent, new HyperHeaderCollection(), body); + public static HyperStatus UnprocessableContent(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableContent, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus UnprocessableContent(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableContent, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus UnprocessableContent(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.UnprocessableContent, headers, null); + public static HyperStatus UnprocessableContent(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableContent, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus UnprocessableContent(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableContent, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus UnprocessableContent(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.UnprocessableContent, headers, body); + public static HyperStatus UnprocessableContent(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableContent, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableEntity.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableEntity.cs index d474449..0629f93 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableEntity.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnprocessableEntity.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus UnprocessableEntity() => new(global::System.Net.HttpStatusCode.UnprocessableEntity, new HyperHeaderCollection(), null); + public static HyperStatus UnprocessableEntity() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableEntity + }; /// /// The body of the response. - public static HyperStatus UnprocessableEntity(object? body) => new(global::System.Net.HttpStatusCode.UnprocessableEntity, new HyperHeaderCollection(), body); + public static HyperStatus UnprocessableEntity(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableEntity, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus UnprocessableEntity(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableEntity, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus UnprocessableEntity(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.UnprocessableEntity, headers, null); + public static HyperStatus UnprocessableEntity(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableEntity, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus UnprocessableEntity(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableEntity, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus UnprocessableEntity(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.UnprocessableEntity, headers, body); + public static HyperStatus UnprocessableEntity(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnprocessableEntity, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnsupportedMediaType.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnsupportedMediaType.cs index d06c01f..18a390c 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnsupportedMediaType.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UnsupportedMediaType.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus UnsupportedMediaType() => new(global::System.Net.HttpStatusCode.UnsupportedMediaType, new HyperHeaderCollection(), null); + public static HyperStatus UnsupportedMediaType() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnsupportedMediaType + }; /// /// The body of the response. - public static HyperStatus UnsupportedMediaType(object? body) => new(global::System.Net.HttpStatusCode.UnsupportedMediaType, new HyperHeaderCollection(), body); + public static HyperStatus UnsupportedMediaType(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnsupportedMediaType, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus UnsupportedMediaType(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnsupportedMediaType, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus UnsupportedMediaType(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.UnsupportedMediaType, headers, null); + public static HyperStatus UnsupportedMediaType(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnsupportedMediaType, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus UnsupportedMediaType(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnsupportedMediaType, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus UnsupportedMediaType(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.UnsupportedMediaType, headers, body); + public static HyperStatus UnsupportedMediaType(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UnsupportedMediaType, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unused.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unused.cs index d33c1a6..b3cdd2e 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unused.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.Unused.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus Unused() => new(global::System.Net.HttpStatusCode.Unused, new HyperHeaderCollection(), null); + public static HyperStatus Unused() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unused + }; /// /// The body of the response. - public static HyperStatus Unused(object? body) => new(global::System.Net.HttpStatusCode.Unused, new HyperHeaderCollection(), body); + public static HyperStatus Unused(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unused, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus Unused(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unused, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus Unused(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.Unused, headers, null); + public static HyperStatus Unused(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unused, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus Unused(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unused, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus Unused(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.Unused, headers, body); + public static HyperStatus Unused(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.Unused, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UpgradeRequired.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UpgradeRequired.cs index 349bb15..b822af6 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UpgradeRequired.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UpgradeRequired.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus UpgradeRequired() => new(global::System.Net.HttpStatusCode.UpgradeRequired, new HyperHeaderCollection(), null); + public static HyperStatus UpgradeRequired() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UpgradeRequired + }; /// /// The body of the response. - public static HyperStatus UpgradeRequired(object? body) => new(global::System.Net.HttpStatusCode.UpgradeRequired, new HyperHeaderCollection(), body); + public static HyperStatus UpgradeRequired(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UpgradeRequired, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus UpgradeRequired(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UpgradeRequired, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus UpgradeRequired(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.UpgradeRequired, headers, null); + public static HyperStatus UpgradeRequired(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UpgradeRequired, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus UpgradeRequired(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UpgradeRequired, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus UpgradeRequired(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.UpgradeRequired, headers, body); + public static HyperStatus UpgradeRequired(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UpgradeRequired, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UseProxy.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UseProxy.cs index eac8398..f5061e1 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UseProxy.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.UseProxy.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus UseProxy() => new(global::System.Net.HttpStatusCode.UseProxy, new HyperHeaderCollection(), null); + public static HyperStatus UseProxy() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UseProxy + }; /// /// The body of the response. - public static HyperStatus UseProxy(object? body) => new(global::System.Net.HttpStatusCode.UseProxy, new HyperHeaderCollection(), body); + public static HyperStatus UseProxy(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UseProxy, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus UseProxy(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UseProxy, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus UseProxy(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.UseProxy, headers, null); + public static HyperStatus UseProxy(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UseProxy, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus UseProxy(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UseProxy, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus UseProxy(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.UseProxy, headers, body); + public static HyperStatus UseProxy(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.UseProxy, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.VariantAlsoNegotiates.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.VariantAlsoNegotiates.cs index 96b8c3e..f5a3af0 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.VariantAlsoNegotiates.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.VariantAlsoNegotiates.cs @@ -1,5 +1,5 @@ // -// Last modified at 2024-06-28. +// Last modified at 2024-07-30. #nullable enable namespace HyperSharp.Protocol @@ -7,19 +7,56 @@ namespace HyperSharp.Protocol public readonly partial record struct HyperStatus { /// - public static HyperStatus VariantAlsoNegotiates() => new(global::System.Net.HttpStatusCode.VariantAlsoNegotiates, new HyperHeaderCollection(), null); + public static HyperStatus VariantAlsoNegotiates() => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.VariantAlsoNegotiates + }; /// /// The body of the response. - public static HyperStatus VariantAlsoNegotiates(object? body) => new(global::System.Net.HttpStatusCode.VariantAlsoNegotiates, new HyperHeaderCollection(), body); + public static HyperStatus VariantAlsoNegotiates(object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.VariantAlsoNegotiates, + Body = body + }; + + /// + /// The body of the response. + /// Which serializer to use to serialize the body. + public static HyperStatus VariantAlsoNegotiates(object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.VariantAlsoNegotiates, + Body = body, + Serializer = serializer + }; /// /// The headers of the response. - public static HyperStatus VariantAlsoNegotiates(HyperHeaderCollection headers) => new(global::System.Net.HttpStatusCode.VariantAlsoNegotiates, headers, null); + public static HyperStatus VariantAlsoNegotiates(HyperHeaderCollection headers) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.VariantAlsoNegotiates, + Headers = headers + }; + + /// + /// The headers of the response. + /// The body of the response. + public static HyperStatus VariantAlsoNegotiates(HyperHeaderCollection headers, object? body) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.VariantAlsoNegotiates, + Headers = headers, + Body = body + }; /// /// The headers of the response. /// The body of the response. - public static HyperStatus VariantAlsoNegotiates(HyperHeaderCollection headers, object? body) => new(global::System.Net.HttpStatusCode.VariantAlsoNegotiates, headers, body); + public static HyperStatus VariantAlsoNegotiates(HyperHeaderCollection headers, object? body, HyperSerializerDelegate serializer) => new HyperStatus() + { + Code = global::System.Net.HttpStatusCode.VariantAlsoNegotiates, + Headers = headers, + Body = body, + Serializer = serializer + }; } } diff --git a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.cs b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.cs index 77e4006..b90fee0 100644 --- a/src/HyperSharp/Protocol/HyperStatus/HyperStatus.cs +++ b/src/HyperSharp/Protocol/HyperStatus/HyperStatus.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics; using System.Net; @@ -13,7 +12,7 @@ public readonly partial record struct HyperStatus /// /// The HTTP status code to respond with. /// - public HttpStatusCode Code { get; init; } + public required HttpStatusCode Code { get; init; } /// /// The headers to be included in the response. @@ -26,43 +25,17 @@ public readonly partial record struct HyperStatus public object? Body { get; init; } /// - /// Creates a new . The status code will be , the headers will be empty, and the body will be null. + /// Which serializer to use to serialize the body. /// - public HyperStatus() : this(HttpStatusCode.NoContent, [], null) { } + public HyperSerializerDelegate Serializer { get; init; } /// - /// Creates a new with the specified status code. The headers will be empty and the body will be null. + /// Creates a new with the specified status code. /// - /// The HTTP status code to respond with. - public HyperStatus(HttpStatusCode code) : this(code, [], null) { } - - /// - /// Creates a new with the specified status code and body. The headers will be empty. - /// - /// The HTTP status code to respond with. - /// The body to be serialized into the response. - public HyperStatus(HttpStatusCode code, object? body) : this(code, [], body) { } - - /// - /// Creates a new with the specified status code and headers. The body will be null. - /// - /// The HTTP status code to respond with. - /// The headers to be included in the response. - public HyperStatus(HttpStatusCode code, HyperHeaderCollection headers) : this(code, headers, null) { } - - /// - /// Creates a new with the specified status code, headers, and body. - /// - /// The HTTP status code to respond with. - /// The headers to be included in the response. - /// The body to be serialized into the response. - public HyperStatus(HttpStatusCode code, HyperHeaderCollection headers, object? body) + public HyperStatus() { - ArgumentNullException.ThrowIfNull(headers, nameof(headers)); - - Code = code; - Headers = headers; - Body = body; + Headers = []; + Serializer = HyperSerializers.JsonAsync; } /// diff --git a/src/HyperSharp/Setup/ExtensionMethods.cs b/src/HyperSharp/Setup/ExtensionMethods.cs index 5e18659..8e0248f 100644 --- a/src/HyperSharp/Setup/ExtensionMethods.cs +++ b/src/HyperSharp/Setup/ExtensionMethods.cs @@ -52,7 +52,7 @@ public static IServiceCollection AddHyperSharp(this IServiceCollection services, public static IServiceCollection AddHyperSharp(this IServiceCollection services, HyperConfigurationBuilder builder) { services.AddSingleton(); - services.AddSingleton(new HyperConfiguration(services, builder)); + services.AddSingleton((serviceProvider) => new HyperConfiguration(serviceProvider, builder)); services.AddSingleton(); return services; }