Routing JSON string in ServiceStack

sirdragon

New Member
I have a service that accepts encrypted JSON data but I want to decrypt that JSON data using an external service so I can pass the unencrypted data to be serialized and handled by the appropriate service handler.The dto for the encrypted data looks like this:\[code\][Route("/encrypted", "POST")]public Encrypted{ public string data { get; set; } // the value stored here is encrypted}\[/code\]Here's a sample dto for the decrypted data:\[code\][Route("/book", "POST")]public Book{ public string author { get; set; }}\[/code\]The decryption and book services look like this:\[code\]public class DecryptionService : Service{ public string Post(Encrypted request) { // decrypt request.data and return the decrypted json string }}public class BookService : Service{ public object Post(Book request) { // return a list of books based on the author }}\[/code\]In the ServiceStack AppHost I read the raw JSON data from the request input stream then Deserialize it to the Encrypted object, then calling the EncryptedService class to decrypt the data and return the unencrypted JSON string:\[code\]// this bit is done in a request filter methodEncrypted encDto = JsonSerializer.DeserializeFromString<Encrypted>(reqInputStreamContent);string jsonResult = new EncryptedService().Post(encDto);\[/code\]I want the requests to come in on their regular resource routes, eg. /book or /person, etc. with the JSON requests looking like:\[code\]{ "data":"some encrypted data"}\[/code\]Then this data gets decrypted and passed on the appropriate verb handler, whether it be Book.Post or Person.Post, etc. The tricky part is I wont know what the plain json request looks like until its decrypted. Its after its decrypted that I'll have to determine which service handler should handle the request.How can I pass unencrypted json string to the appropriate service handler? I tried Deserializing the decrypted json string to an object then publish the object in hopes that the correct registered message handler would pick it up and handler it, that didn't work though.
 
Top