servicestack-bsd

ServiceStack “new” api and async await

放肆的年华 提交于 2019-12-05 08:07:51
ServiceStack version 3 I'm quite familiar with https://github.com/ServiceStack/ServiceStack/wiki/New-API and on this page it specifically says "All these APIs have async equivalents which you can use instead, when you need to." Is it possible to use async await with ServiceStack's new api? What would the server and client code look like with async await? [Route("/reqstars")] public class AllReqstars : IReturn<List<Reqstar>> { } public class ReqstarsService : Service { public List<Reqstar> Any(AllReqstars request) { return Db.Select<Reqstar>(); } } Client var client = new JsonServiceClient

Access Servicstack.net session in validator

旧时模样 提交于 2019-12-01 08:09:06
How can I access a ServiceStack.net session in my validation code? public class UserSettingsValidator : AbstractValidator<UserSettingsRequest> { public UserSettingsValidator() { RuleFor(x => x.UserId) .SetValidator(new PositiveIntegerValidator()) .SetValidator(new UserAccessValidator(session.UserId)); //<-- I need to pass the UserID from the session here } } In the Service Implementation I just do: var session = base.SessionAs<UserSession>(); but this does not work for my abstract validator. Thanks! Edit: this is version 3.9.71.0 I assume you are just using the ValidationFeature plugin, as

Access Servicstack.net session in validator

蹲街弑〆低调 提交于 2019-12-01 06:51:57
问题 How can I access a ServiceStack.net session in my validation code? public class UserSettingsValidator : AbstractValidator<UserSettingsRequest> { public UserSettingsValidator() { RuleFor(x => x.UserId) .SetValidator(new PositiveIntegerValidator()) .SetValidator(new UserAccessValidator(session.UserId)); //<-- I need to pass the UserID from the session here } } In the Service Implementation I just do: var session = base.SessionAs<UserSession>(); but this does not work for my abstract validator.

Enable gzip/deflate compression

北城以北 提交于 2019-11-27 18:31:37
问题 I'm using ServiceStack (version 3.9.44.0) as a Windows Service (so I'm not using IIS) and I use both its abilities both as an API and for serving web pages. However, I haven't been able to find how exactly I should enable compression when the client supports it. I imagined that ServiceStack would transparently compress data if the client's request included the Accept-Encoding:gzip,deflate header, but I'm not seeing any corresponding Content-Encoding:gzip in the returned responses. So I have a