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

Method get

lib/server.ts:173–196  ·  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

171 * @param {Object} res The response object
172 */
173 get(req: express.Request, res: express.Response): void {
174 const thing = this.getThing(req);
175 if (thing === null) {
176 res.status(404).end();
177 return;
178 }
179
180 const wsHref = `${req.secure ? 'wss' : 'ws'}://${req.headers.host}`;
181 const description = thing.asThingDescription();
182 description.links.push({
183 rel: 'alternate',
184 href: `${wsHref}${thing.getHref()}`,
185 });
186 description.base =
187 `${req.protocol}://${req.headers.host}${thing.getHref()}`;
188 description.securityDefinitions = {
189 nosec_sc: {
190 scheme: 'nosec',
191 },
192 };
193 description.security = 'nosec_sc';
194
195 res.json(description);
196 }
197
198 /**
199 * Handle a websocket request.

Callers 1

constructorMethod · 0.95

Calls 3

asThingDescriptionMethod · 0.80
getThingMethod · 0.45
getHrefMethod · 0.45

Tested by

no test coverage detected