[Path()] attributeThe The public class MyAPI
{
[Path("/api/foo")]
public void Stuff()
{
Console.WriteLine("got a request for /api/foo!");
}
}
The path string allows some special syntax that allows a component of the path to vary and map to a method parameter: public class MyAPI
{
[Path("/api/foo/{bar}")]
public void Stuff(string bar)
{
Console.WriteLine("got a request for /api/foo/" + bar + "!");
}
}
What's really going on here is that when // extend from KayakService for access to the current KayakContext
public class MyAPI : KayakService
{
[Path("/api/foo/{bar}")]
public void Stuff()
{
NameValueDictionary params = Context.Items[MethodMap.PathParamsContextKey];
Console.WriteLine("/api/foo/" + params["bar"] + "!");
}
}
Methods marked only with |