MCPcopy Index your code
hub / github.com/WebThingsIO/webthing-node / get

Method get

lib/server.ts:362–375  ·  view source on GitHub ↗

* Handle a GET request. * * @param {Object} req The request object * @param {Object} res The response object

(req: express.Request, res: express.Response)

Source from the content-addressed store, hash-verified

360 * @param {Object} res The response object
361 */
362 get(req: express.Request, res: express.Response): void {
363 const thing = this.getThing(req);
364 if (thing === null) {
365 res.status(404).end();
366 return;
367 }
368
369 const propertyName = req.params.propertyName;
370 if (thing.hasProperty(propertyName)) {
371 res.json({[propertyName]: thing.getProperty(propertyName)});
372 } else {
373 res.status(404).end();
374 }
375 }
376
377 /**
378 * Handle a PUT request.

Callers 1

constructorMethod · 0.95

Calls 3

hasPropertyMethod · 0.80
getPropertyMethod · 0.80
getThingMethod · 0.45

Tested by

no test coverage detected