work towards path parameters
This commit is contained in:
@@ -5,9 +5,6 @@
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class ParameterAttribute : Attribute {
|
||||
// See the attribute guidelines at
|
||||
// http://go.microsoft.com/fwlink/?LinkId=85236
|
||||
|
||||
public string Name { get; }
|
||||
public bool IsOptional { get; }
|
||||
public ParameterAttribute(string name, bool isOptional = false) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace SimpleHttpServer.Types;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the name of a http endpoint path parameter. Path parameter names must be in the format $1, $2, $3, ..., and the end of the path may be $*
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class PathParameterAttribute : Attribute {
|
||||
public string Name { get; }
|
||||
public PathParameterAttribute(string name) {
|
||||
if (string.IsNullOrWhiteSpace(name)) {
|
||||
throw new ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name));
|
||||
}
|
||||
|
||||
if (!name.StartsWith('$')) {
|
||||
throw new ArgumentException($"'{nameof(name)}' must start with $.", nameof(name));
|
||||
}
|
||||
|
||||
if (name.Contains(' ')) {
|
||||
throw new ArgumentException($"'{nameof(name)}' must not contain spaces.", nameof(name));
|
||||
}
|
||||
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user