servicestack

ServiceExceptionHandler usage on RestServiceBase<T>

亡梦爱人 提交于 2019-11-29 11:05:13
I'm trying to use the ServiceExceptionHandler on my Serivce which extends RestServiceBase<TViewModel> I can use the AppHost.ServiceExceptionHandler , that's working fine. I need the user info from the HttpRequest , thats not available at AppHost level. So I'm trying to use the ServiceExceptionHandler on Service level. Though I set the delegate on service ctor , it's null when exception thrown on OnGet method public class StudentService : RestServiceBase<Student> { public StudentService() { ServiceExceptionHandler = (request, exception) => { logger.Error(string.Format("{0} - {1} \n Request : {2

Need help on servicestack implementation

强颜欢笑 提交于 2019-11-29 10:50:59
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

Is it possible to customize the ServiceStack /metadata page?

一曲冷凌霜 提交于 2019-11-29 10:14:20
I run my site behind a loadbalancer on a non-standard port. When loading up the /metadata page it has my public domain name yet the local port that the app is hosted on, which causes the links to the different formats to break as well. Example: in the browser: http://mydomain.com/api/metadata in metadata page: http://mydomain.com:10000/api/metadata Is there a way to customize these links in the output? Further, is it possible to customize the other text/css/etc of the page, such that it can be modified to fit into the template I use for the rest of my site? v4 Update v4 ServiceStack provides a

Multi-tenant ServiceStack API, same deployment to respond to requests on different hostnames?

馋奶兔 提交于 2019-11-29 09:04:40
问题 We're creating APIs using ServiceStack that are multi-tenant. We want to do DNS-based load-balancing and routing, rather than stitch things up via a reverse proxy (like nginx or haproxy). We have Request DTOs that have a Tenant parameter. ServiceStack (and its SwaggerFeature) allow us to define custom routes, and document the DTOs such that we can read values from path, query, headers, or body. How do we (best) wire things so that DTO properties can read values from a hostname pattern as well

How to find Service from ServiceStack RequestFilter

旧街凉风 提交于 2019-11-29 08:57:30
I'm trying to implement a RequestFilter that conditionally executes, based on information in the Service that would get invoked. I'd like to make the RequestFilter find the Service , look at it for a method/interface/attribute, and conditionally do its work based on that. I'm aware that you can declare a RequestFilterAttribute on the Service , but I couldn't figure out a good way to make it conditional. I wanted to pass a delegate/lambda into the attribute, but C# doesn't allow that. I could have plugged in a Type or type name into there, allowing the RequestFilterAttribute to find the Service

How to register multiple IDbConnectionFactory instances using Funq in ServiceStack.net part 2

一曲冷凌霜 提交于 2019-11-29 08:48:55
ServiceStack has delivered on EVERYTHING I've thrown at it, except the SAAS (Multi-tenant) use case where single API instance is using several databases of the same schema, one per tenant. These databases, because of legal reasons need to be housed in separate instances. So, my question is this, "Is it possible to change the connection per Request based on meta from a filter? My question is somewhat similar to this one , but with the added twist that each database is the same. Thank you, Stephen Edit: If memory serves me correctly I think mythz and I have discussed this before and found that

XML deserializing only works with namespace in xml

让人想犯罪 __ 提交于 2019-11-29 06:47:26
The most simple way I get ServiceStack xml deserialization to work is when the xml contains a namespace. However, the xml I receive do not contain namespaces. The most simple working example: [Serializable] public class test { } class Program { static void Main(string[] args) { string xml="<test xmlns=\"http://schemas.datacontract.org/2004/07/\"></test>"; var result = ServiceStack.Text.XmlSerializer.DeserializeFromString<test>(xml); } } However, that is not what I want. I want the following to deserialize, since that is the xml I get from several services: string xml="<test></test>"; But that

How to retrieve auto-incremented Id in ServiceStack OrmLite?

随声附和 提交于 2019-11-29 05:54:10
问题 For a table that has an identity: [AutoIncrement] public int Id { get; set;} When inserting a new row into the database, what is the best way to retrieve the Id of the object? For example: db.Insert<> (new User()); The value of the Id is 0 after the insert, but in the database this obviously is not the case. The only possibility I can see is the following: Id = (int)db.GetLastInsertId(); However I don't believe this would be a safe call to make. If there are 100's of inserts happening at the

Unit Test HTTPRequest Headers with ServiceStack

你离开我真会死。 提交于 2019-11-29 02:21:03
I have this Service: public class PlayerService : Service { public IPlayerAppService PlayerAppService { get; set; } public PlayerService (IPlayerAppService service) { if (service == null) throw new ArgumentException ("Service null"); PlayerAppService = service; } public object Post (PlayerDTO request) { var newPlayer = new PlayerResponse () { Player = PlayerAppService.SendPlayerLocation(request.Position.Latitude, request.Position.Longitude) }; return new HttpResult (newPlayer) { StatusCode = System.Net.HttpStatusCode.Created, Headers = { { HttpHeaders.Location, base.Request.AbsoluteUri

ServiceStack IReturn

左心房为你撑大大i 提交于 2019-11-29 01:52:55
I am looking at the new api that came out 2 weeks ago. It seems like ReqDTO : IReturn<List<ResDTO>> { //... } The "IReturn" bit seems to be optional? The DTOs in RazorRockstars demo project works without it. This is a new addition in ServiceStack's New API which allows you to document the expected Response Type that the Request DTO will return, e.g. with ReqDTO : IReturn<List<ResDTO>> { ... } Which lets you call using any of the C# Service Clients with: List<ResDTO> response = client.Get(new ReqDto()); If you didn't have the IReturn marker your client call would have to look like: List<ResDTO>