From Lightweight Nancy to ServiceStack
Working on a project for a client, I decided to use ServiceStack. I found ServiceStack’s learning curve to be smooth. It feels natural for a C# Developer and Solution Architect.
While I was using ServiceStack version 4, I reached the limit of creating 10 request DTOs (Data Transfer Objects). This limit was not there for ServiceStack version 3. Since this is no small application and not ready to shell out the $299 required for a Starter licence, I have therefore switched to Nancy.
I found migrating from ServiceStack to Nancy smooth because:
- They have similar service implementation. In ServiceStack, you implement your service using ServiceStack.Service. In Nancy, you do the same using Nancy.NancyModule. You have a “Service” in ServiceStack and a “Module” in Nancy.
- I used request/response DTOs created earlier in the project. I simply reused those DTOs in the new Nancy modules.
- The routing information for Nancy is very similar to ServiceStack::
Nancy:
Get[“/v1/samplerequests”]
VS
ServiceStack:
[Route(“/v1/samplerequests”, RestVerbs.GET)]
public class GetSampleRequests : IReturn<TResponse>
That’s it! Apart from Web.Config settings, that’s mostly what you have to do to migrate from one web framework to another. Just be sure your code is clean and well structured.
Leave a Reply