同じタイプで URI が異なる 2 つのハンドラーを登録する場合、ハンドラー選択アルゴリズムは、使用するハンドラーを決定するときに uri をチェックしていないようです。
以下のプログラムを実行すると、HandlerOne だけが (2 回) 呼び出されることがわかります。"/one" と "/two" のどちらを呼び出すかは関係ありません。後者は HandlerTwo によって処理されるはずです。
私は何か間違ったことをしていますか、それとも OpenRasta で修正されるものですか? (私は2.0.3.0を使用しています)
class Program
{
static void Main(string[] args)
{
using (InMemoryHost host = new InMemoryHost(new Configuration()))
{
host.ProcessRequest(new InMemoryRequest
{
HttpMethod = "GET",
Uri = new Uri("http://x/one")
});
host.ProcessRequest(new InMemoryRequest
{
HttpMethod = "GET",
Uri = new Uri("http://x/two")
});
}
}
}
class Configuration : IConfigurationSource
{
public void Configure()
{
using (OpenRastaConfiguration.Manual)
{
ResourceSpace.Has.ResourcesOfType(typeof(object))
.AtUri("/one").HandledBy(typeof(HandlerOne));
ResourceSpace.Has.ResourcesOfType(typeof(object))
.AtUri("/two").HandledBy(typeof(HandlerTwo));
}
}
}
class HandlerOne
{
public object Get() { return "returned from HandlerOne.Get"; }
}
class HandlerTwo
{
public object Get() { return "returned from HandlerTwo.Get"; }
}
更新http://trac.caffeine-it.com/openrasta/wiki/Doc/Handlers/MethodSelectionで 説明されているように、 UriNameHandlerMethodSelector を使用して同様のことを達成できると感じていますが、各ハンドラーに注釈を付ける必要がありますメソッドと AtUri().Named() も実行します。これは定型文のように見えますが、これは避けたいと思います。AtUri(X).HandledBy(Y) は X と Y の接続を明確にしていませんか?