Skip to content

Instantly share code, notes, and snippets.

@steff-mueller
Created January 2, 2012 13:52
Show Gist options
  • Save steff-mueller/1550758 to your computer and use it in GitHub Desktop.
Save steff-mueller/1550758 to your computer and use it in GitHub Desktop.
ServiceStack improvement
[RestService("/users", Verbs = "POST, GET")]
public class User
{
...
}
public class UserResponse
{
...
}
public class UserCreationResponse
{
...
}
public class UserService : ServiceBase,
IGetResponse<UserResponse>,
IPostResponse<UserCreationResponse>
{
public UserResponse OnGet()
{
...
return new UserResponse();
}
public UserCreationResponse OnPost()
{
...
return new UserCreationResponse();
}
}
  • Type of response is still predictable for the client
  • On exception, response can still be created on the fly (generic must be new())
  • End-user isn't force to compose all properties in one single response DTO
  • End-user doesn't need to follow naming convention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment