Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a basic create/read/update/delete service


When you're building a REST service, it's important to make good use of the main tool available to you, HTTP. There are multiple books on the subject of what makes a good RESTful service, but here are some of the headlines:

  • URL routes represent resources; they should be nouns, not verbs

  • Services should act predictably to common verbs, for example, GET, POST, PUT, DELETE

  • Use appropriate HTTP status codes for responses

In this recipe, we will build a simple service that will Create, Read, Update, and Delete (CRUD) entries from a database. For a deeper dive into some of the other concepts used in this example, please see the relevant recipes:

  • The Sharing and accessing configuration and common functionality using Funq IoC recipe in Chapter 1, Configuration and Routing

  • The Using and accessing OrmLite recipe in Chapter 4, Object Relational Mapping (OrmLite)

  • The Creating static validation rules using fluent syntax recipe in Chapter 6, Filters and Validators...