servicestack

ServiceStack - Using gzip/deflate compression with JSONP requests

廉价感情. 提交于 2019-12-03 13:27:27
I have a ServiceStack service that compresses the response using RequestContext.ToOptimizedResult() , e.g.: [Route("/numbers/search")] public class FindNumbers { } public object Get(FindNumbers query) { var data = new List<string> { "One", "Two", "Three" }; return RequestContext.ToOptimizedResult(data); } This works perfectly when issuing a request like: GET http://myhost:13487/numbers/search.json And is compressed as expected with the Accept-Encoding request header: Accept-Encoding: gzip,deflate,sdch I can also issue a JSONP request: GET http://myhost:13487/numbers/search?callback=func which

With OrmLite, is there a way to automatically update table schema when my POCO is modified?

…衆ロ難τιáo~ 提交于 2019-12-03 12:57:38
Can OrmLite recognize differences between my POCO and my schema and automatically add (or remove) columns as necessary to force the schema to remain in sync with my POCO? If this ability doesn't exist, is there way for me to query the db for table schema so that I may manually perform the syncing? I found this , but I'm using the version of OrmLite that installs with ServiceStack and for the life of me, I cannot find a namespace that has the TableInfo classes. No there is no current support for Auto Migration of RDBMS Schema's vs POCOs in ServiceStack's OrmLite . There are currently a few

How to set up handlers in RedMQ from events raised in my domain

柔情痞子 提交于 2019-12-03 12:43:26
Just getting my head around message queues and Redis MQ , excellent framework. I understand that you have to use .RegisterHandler(...) to determine which handler will process the type of message/event that is in the message queue. So if I have EventA, EventB etc should I have one Service which handles each of those Events, like : public class DomainService : Service { public object Any(EventA eventA) {...} public object Any(EventB eventA) {...} } So these should be only queue/redis list created? Also, what If I want a chain of events to happen, so for example a message of type EventA also has

Redis serviceStack pooled connection client

这一生的挚爱 提交于 2019-12-03 12:39:23
I'm designing a web service which uses Redis as a database, and I want to know the best practices for using Redis connecting with StackService client. The point is that I've been reading about Redis and I found that the best way to interact with the server is by using a single concurrent connection. The problem is that despite I'm using PooledRedisClientManager each time that a web client makes a request to the web service I get a one more connected client (opened connection) to the redis server and this number of connected client increases without limit consuming more and more memory. The

ServiceStack OrmLite Sql Query Logging

馋奶兔 提交于 2019-12-03 12:21:39
问题 As per the Service Stack Ormlite documentation. I should generate the sql query in debug mode. But, I am not able to see those queries. Simple code private static readonly string DataDirLoc = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TargetIntegration\\Test\\Debug\\"; private readonly string dbFileName = DataDirLoc + "Test.db3"; [Test] public void Can_Generate_log() { //var writer = new TextWriterTraceListener(System.Console.Out); //Debug.Listeners.Add(writer);

Bad gateway 502 after small load test on fastcgi-mono-server through nginx and ServiceStack

懵懂的女人 提交于 2019-12-03 10:05:20
问题 I am trying to run a webservice API with ServiceStack under nginx and fastcgi-mono-server. The server starts fine and the API is up and running. I can see the response times in the browser through ServiceStack profiler and they run under 10ms. But as soon as I do a small load test using "siege" (only 500 requests using 10 connections), I start getting 502 Bad Gateway. And to recover, I have to restart the fastcgi-mono-server. The nginx server is fine. The fastcgi-mono-server is the one that

How do I translate complex objects in ServiceStack?

旧街凉风 提交于 2019-12-03 09:23:22
Suppose I have two objects: class Order { string Name {get; set;} Customer Customer {get; set;} Item[] Items {get; set;} } and class OrderDTO { string Name {get; set;} CustomerDTO Customer {get; set;} ItemDTO[] Items {get; set;} } If I receive an object orderDTO that is fully populated and do orderDTO.TranslateTo<Order>() the result will only have Name populated, not Customer or Items . Is there a way to do a recursive translation or the only option is to translate Customer and each of the Items manually? I would wrap this in a re-usable extension method, e.g: public static OrderDTO ToDto(this

ServiceStack.Redis.Sentinel Usage

放肆的年华 提交于 2019-12-03 09:10:36
I'm running a licensed version of ServiceStack and trying to get a sentinel cluster setup on Google Cloud Compute. The cluster is basically GCE's click-to-deploy redis solution - 3 servers. Here is the code i'm using to initialize... var hosts = Settings.Redis.Host.Split(';'); var sentinel = new ServiceStack.Redis.RedisSentinel(hosts, "master"); redis = sentinel.Setup(); container.Register<IRedisClientsManager>(redis); container.Register<ICacheClient>(redis.GetCacheClient()); The client works fine - but once i shut down one of the redis instances everything craps the bed. The client complains

Does ServiceStack support Token based authentication?

匿名 (未验证) 提交于 2019-12-03 09:10:12
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Asp.net Web api has out of the box support for token based authentication with minor configuration settings. I havent found anything like that for servicestack. Is there anyway how I can setup servicestack to provide tokens on authentication instead of session id. 回答1: ServiceStack includes support for JWT built-in there are also a couple of other projects that enable token-based authentication with ServiceStack: StatelessAuthentication Using IdentityServer 4 with ServiceStack and Angular Auth0 ServiceStack Integration ServiceStack JWT Token

Stop Fluent Validation on first failure

落花浮王杯 提交于 2019-12-03 08:53:53
问题 i'm defining a validation for my Request objects. I would like the validator to stop on the very first failure, not only the one on the same chain. In the example below, if my TechnicalHeader object is null, i get a NullReference exception when the validation reaches the rule for TechnicalHeader.MCUserid . In poor words, i would like to do a conditional validation over the last three rules in the code below, according to the result of the first rule using System; using ServiceStack