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

Adding custom headers via the response filter


In some situations, developers might need to attach custom headers to requests and responses from your web service APIs. An example of this might be additional information about a resource in the response, such as an expiry date. In this example, we will have a look at adding a custom header to the response via an attribute filter.

Getting ready

If you are using a non-express version of Visual Studio, you can start this recipe using ServiceStackVS and creating a project based on the ServiceStack ASP.NET Empty template. In this example, we are going to use Postman as the client to test and view the custom headers in the response. If you are using an express version of Visual Studio, please follow Creating a ServiceStack solution with Visual Studio and NuGet in Appendix A, Getting Started and start from the third instruction in the following How to do it... section.

How to do it…

  1. Create a new project using a template from the ServiceStackVS extension...