* Handle a GET request. * * @param {Object} req The request object * @param {Object} res The response object
(req: express.Request, res: express.Response)
| 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. |
no test coverage detected