work towards path parameters
This commit is contained in:
1 parent
2e4570a560
commit
a24543063b
3 files changed
+44
-11
No files matched your search
@@ -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