aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/static.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-08 21:16:10 +0100
committerGitHub <noreply@github.com>2020-12-08 21:16:10 +0100
commitf2eb23cd87cf32b8fe545178143b5f49e06a58da (patch)
treeaf7d59945af70e28fd85047e2c688c59a908f548 /server/controllers/static.ts
parentc977fd3ec931c059111ddb2b8d6ddbb20b6b99a1 (diff)
downloadPeerTube-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.ts14
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'
27import { getThemeOrDefault } from '../lib/plugins/theme-utils' 27import { getThemeOrDefault } from '../lib/plugins/theme-utils'
28import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config' 28import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config'
29import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 29import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
30import { serveIndexHTML } from '@server/lib/client-html'
30 31
31const staticRouter = express.Router() 32const staticRouter = express.Router()
32 33
@@ -119,6 +120,11 @@ staticRouter.get('/robots.txt',
119 } 120 }
120) 121)
121 122
123staticRouter.all('/teapot',
124 getCup,
125 asyncMiddleware(serveIndexHTML)
126)
127
122// security.txt service 128// security.txt service
123staticRouter.get('/security.txt', 129staticRouter.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
401function 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}