Guide
Installation
| 1 | npm install @xpulse/http --registry=https://npm.xpulse.one |
Minimales Beispiel
| 1 | import http from '@xpulse/http'; |
| 2 | |
| 3 | await http.init(); |
| 4 | |
| 5 | http.route('GET', '/', (req, res) => { |
| 6 | res.send('<h1>xPulse</h1>'); |
| 7 | }); |
| 8 | |
| 9 | http.route('GET', '/health', (req, res) => { |
| 10 | res.status(200).send('ok'); |
| 11 | }); |
| 12 | |
| 13 | http.start(); |
| 14 | process.on('SIGTERM', () => http.stop()); |
Trailing Slash
Der Server erzwingt einen Trailing Slash fuer alle Pfade ausser /.
/health wird automatisch auf /health/ umgeleitet (308).