namespace SimpleHttpServer.Types; /// /// 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 $* /// [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; } }