diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-08 21:16:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 21:16:10 +0100 |
commit | f2eb23cd87cf32b8fe545178143b5f49e06a58da (patch) | |
tree | af7d59945af70e28fd85047e2c688c59a908f548 /server/controllers/static.ts | |
parent | c977fd3ec931c059111ddb2b8d6ddbb20b6b99a1 (diff) | |
download | PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.gz PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.zst PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.zip |
emit more specific status codes on video upload (#3423)
- reduce http status codes list to potentially useful codes
- convert more codes to typed ones
- factorize html generator for error responses
Diffstat (limited to 'server/controllers/static.ts')
-rw-r--r-- | server/controllers/static.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index ff77452dd..f12f00e1b 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -27,6 +27,7 @@ import { getTorrentFilePath, getVideoFilePath } from '@server/lib/video-paths' | |||
27 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' | 27 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' |
28 | import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config' | 28 | import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config' |
29 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 29 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
30 | import { serveIndexHTML } from '@server/lib/client-html' | ||
30 | 31 | ||
31 | const staticRouter = express.Router() | 32 | const staticRouter = express.Router() |
32 | 33 | ||
@@ -119,6 +120,11 @@ staticRouter.get('/robots.txt', | |||
119 | } | 120 | } |
120 | ) | 121 | ) |
121 | 122 | ||
123 | staticRouter.all('/teapot', | ||
124 | getCup, | ||
125 | asyncMiddleware(serveIndexHTML) | ||
126 | ) | ||
127 | |||
122 | // security.txt service | 128 | // security.txt service |
123 | staticRouter.get('/security.txt', | 129 | staticRouter.get('/security.txt', |
124 | (_, res: express.Response) => { | 130 | (_, res: express.Response) => { |
@@ -391,3 +397,11 @@ function getHLSPlaylist (video: MVideoFullLight) { | |||
391 | 397 | ||
392 | return Object.assign(playlist, { Video: video }) | 398 | return Object.assign(playlist, { Video: video }) |
393 | } | 399 | } |
400 | |||
401 | function getCup (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
402 | res.status(HttpStatusCode.I_AM_A_TEAPOT_418) | ||
403 | res.setHeader('Accept-Additions', 'Non-Dairy;1,Sugar;1') | ||
404 | res.setHeader('Safe', 'if-sepia-awake') | ||
405 | |||
406 | return next() | ||
407 | } | ||