I an facing issue with my servicestack implementation, i have make followings requests url to call my service and implemented one perfmon class & perfmonservice class
[RestService("/perfmon/application/{appliationId}")]
[RestService("/perfmon/application/{appliationId}/{countername}")]
[RestService("/perfmon/user/{userId}")]
[RestService("/perfmon/user/{userId}/{countername}")]
Now when i will call any of the URL it would call following function
public override object OnGet(Perfmon request)
{
return base.OnGet(request);
}
so how can i decide here that which URL made this call , weather servicestack provide any specific way to do this or i need to write manual logic by checking properties?
Thanks in Advance
Just inspect the request DTO to see which fields are populated, i.e.
if (request.applicationId != null && request.countername != null) #2
if (request.userId != null && request.countername != null) #4
if (request.applicationId != null) #1
if (request.userid != null) #3
Also note that the user can populate the request dto with the querystring as well, i.e. if they called you with:
/perfmon/application/1/countername?userId=2
Then all fields will be populated. Lastly you can retrieve information about the Request with like the Absolute URI used to call the request with:
base.RequestContext.AbsoluteUri
Finally you can get the IHttpRequest object itself with:
var httpReq = base.Request; //or with base.RequestContext.Get<IHttpRequest>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With