using System;
namespace EmbedIO.Routing
{
///
/// Decorate methods within controllers with this attribute in order to make them callable from the Web API Module
/// Method Must match the WebServerModule.
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class RouteAttribute : Attribute
{
///
/// Initializes a new instance of the class.
///
/// if this attribute represents a base route;
/// (the default) if it represents a terminal (non-base) route.
/// The verb.
/// The route.
/// is .
///
/// is empty.
/// - or -
/// does not start with a slash (/) character.
/// - or -
/// does not comply with route syntax.
///
///
public RouteAttribute(HttpVerbs verb, string route, bool isBaseRoute = false)
{
Matcher = RouteMatcher.Parse(route, isBaseRoute);
Verb = verb;
}
///
/// Gets the HTTP verb handled by a method with this attribute.
///
public HttpVerbs Verb { get; }
///
/// Gets a that will match URLs against this attribute's data.
///
public RouteMatcher Matcher { get; }
///
/// Gets the route handled by a method with this attribute.
///
public string Route => Matcher.Route;
///
/// Gets a value indicating whether this attribute represents a base route.
///
public bool IsBaseRoute => Matcher.IsBaseRoute;
}
}