DPS907 notes – Thu Oct 2

Hypermedia-driven web API design, continued: Handling the HTTP OPTIONS method. Help your web service users. Work on Lab 4.

.

Add support for the HTTP ‘OPTIONS’ method

A hypermedia-driven design needs to support the HTTP OPTIONS method.

This enables a requestor to determine what HTTP methods are supported by a URI, before sending the actual request.

The recommended approach is to create a ‘handler’, which will intercept and process any request that uses the OPTIONS method. This is a better alternative to writing code in every controller.

Your professor will explain the design and function of the HttpOptionsMethodHandler class during this class session.

Your professor acknowledges the post by Jef Claes that enabled today’s handler to get written. Then, Yao Huang Lin’s post provided the knowledge that resulted in it covering all kinds of URIs.

.

Configure an entry point URI for the web service

A hypermedia-driven design also needs an ‘entry point URI’.

The idea is that the web service provider can publish one single URI for the web service, and clients/requestors will be able to discover all of the resources.

To do this, we must perform these steps:

  1. Add a default value for the ‘controller’ placeholder, in the App_Start > WebApiConfig class
  2. Add a new ApiController class that uses the value you provided above
  3. Implement a single ‘get’ method, which returns a collection of link relations

.

Work on Lab 4

You can get started on Lab 4.

As a base project, you can use a copy of your Lab 3 work, or you can download a ‘Lab 4 base project’ that was posted by your professor.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: