mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
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
This commit is contained in:
parent
c977fd3ec9
commit
f2eb23cd87
53 changed files with 506 additions and 310 deletions
|
@ -27,6 +27,7 @@ import { getTorrentFilePath, getVideoFilePath } from '@server/lib/video-paths'
|
|||
import { getThemeOrDefault } from '../lib/plugins/theme-utils'
|
||||
import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
import { serveIndexHTML } from '@server/lib/client-html'
|
||||
|
||||
const staticRouter = express.Router()
|
||||
|
||||
|
@ -119,6 +120,11 @@ staticRouter.get('/robots.txt',
|
|||
}
|
||||
)
|
||||
|
||||
staticRouter.all('/teapot',
|
||||
getCup,
|
||||
asyncMiddleware(serveIndexHTML)
|
||||
)
|
||||
|
||||
// security.txt service
|
||||
staticRouter.get('/security.txt',
|
||||
(_, res: express.Response) => {
|
||||
|
@ -391,3 +397,11 @@ function getHLSPlaylist (video: MVideoFullLight) {
|
|||
|
||||
return Object.assign(playlist, { Video: video })
|
||||
}
|
||||
|
||||
function getCup (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
res.status(HttpStatusCode.I_AM_A_TEAPOT_418)
|
||||
res.setHeader('Accept-Additions', 'Non-Dairy;1,Sugar;1')
|
||||
res.setHeader('Safe', 'if-sepia-awake')
|
||||
|
||||
return next()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue