O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing control action

As in the case for the /Momentary resource, we check the Accept header to see how the client wants the response to be represented. If no such header is available, we will assume XML is requested. If an unrecognized content type is requested, we make sure to return a 406 Not Acceptable response before we perform the control action:

if (req.Header.Accept != null) { switch (req.Header.Accept.GetBestContentType("text/xml", "application/xml", "application/json")) { case "text/xml": case "application/xml": await this.SetOutput(OutputValue, req.RemoteEndPoint); this.ReturnMomentaryAsXml(req, resp); break; case "application/json": await this.SetOutput(OutputValue, req.RemoteEndPoint); this.ReturnMomentaryAsJson(req, resp); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required