prashant
prashant

Reputation: 2209

Issue with Openrasta's Get methods' precedence in resource handler

I am new to openRasta framework. I have a resource called Project.I have 2 different types of GET to be done on this resource as i need different info on these two GETs.My configuration is like this

ResourceSpace.Has.ResourcesOfType<IList<Project>>()
     .AtUri("/projects")
     .And.AtUri("/miniprojects")  
     .HandledBy<ProjectHandler>()
     .AsJsonDataContract()
     .And.AsXmlDataContract();

and my methods in Handler are as below

[HttpOperation(HttpMethod.GET, ForUriName = "/projects")]
public OperationResult GetProjectsList()
{
}

[HttpOperation(HttpMethod.GET, ForUriName = "/miniprojects")]
public OperationResult GetMiniProjectList()
{
} 

Whenever i am doing some GET on this resource, whatever my URL is for example http://localhost/projects or http://localhost/miniprojects) the very first method with GetXXX name in handler class gets called every time. When I changed the sequence of the GetXXX methods in handler file the other method gets called.
So my question is, does sequence of methods in Handler determines which GetXXX method to be called? Moreover, I specified different "ForUriName" in the HttpOperation attribute for each GetXXX method as mentioned in the snippet, but still the sequence took the precedence.

Can any one help me in resolving this issue? Or let me know if I am missing anything.

Thanks in advance.

Upvotes: 2

Views: 302

Answers (1)

SerialSeb
SerialSeb

Reputation: 6766

If threre is no way do make the distinction between two URIs then we don't guarantee any order at all.

If you really want to use URI routes in this way (as opposed to model different resources), then your uri needs to be registered with a name

.AtUri("/miniprojects").Named("miniprojects")

The Named bit needs to match the attribute

[HttpOperation(ForUriName="miniprojects")]

Upvotes: 3

Related Questions