Introduce HttpController interface for http routers (#7142)

By requiring controllers to declare their own routes, we ensure
consistency between tests and the actual server
This commit is contained in:
Mats Jun Larsen
2024-11-29 00:12:06 +09:00
committed by GitHub
parent a895b7b365
commit b29a0809ad
8 changed files with 69 additions and 16 deletions

10
app.ts
View File

@@ -872,13 +872,9 @@ async function main() {
);
})
.use(bodyParser.json({limit: ceProps('bodyParserLimit', maxUploadSize)}))
.get('/api/siteTemplates', siteTemplateController.getSiteTemplates.bind(siteTemplateController))
.get('/source/:source/list', sourceController.listEntries.bind(sourceController))
.get('/source/:source/load/:language/:filename', sourceController.loadEntry.bind(sourceController))
.get(
'/api/asm/:arch/:opcode',
assemblyDocumentationController.getOpcodeDocumentation.bind(assemblyDocumentationController),
)
.use(siteTemplateController.createRouter())
.use(sourceController.createRouter())
.use(assemblyDocumentationController.createRouter())
.get('/g/:id', oldGoogleUrlHandler)
// Deprecated old route for this -- TODO remove in late 2021
.post('/shortener', routeApi.apiHandler.shortener.handle.bind(routeApi.apiHandler.shortener));