Alison Lee
Alison Lee

Reputation: 270

Use of Options in RESTful Web services

In RESTful web service, is OPTIONS method is supposed to be used to provide a list of available services? If yes, is that mandatory, or just a good programming practice.

Thank you

Upvotes: 3

Views: 2803

Answers (2)

dhwthompson
dhwthompson

Reputation: 2509

A response to an OPTIONS request should provide some information about what the client can do with the resource in question. The most obvious example is to show which methods the resource will respond to, probably using an Allow header. You could also respond with the Accept-Ranges header to show when you support range requests.

In practice, though, the Allow header is the only common use of the OPTIONS method, and even then implementation is far from universal. So it’s a nice feature to have, but isn’t likely to make a huge difference in a real world service.

Upvotes: 3

Julian Reschke
Julian Reschke

Reputation: 42017

It's definitively not mandatory but certainly an option.

But keep in mind that to use OPTIONS for service discovery you'll need extension header fields or a custom response media type, in which case GET might work better in practice.

Upvotes: 1

Related Questions