Add /list/ routes to service

pull/3/head
Amio 2018-06-23 16:51:51 +08:00
rodzic b6014b1d22
commit f40f21eeaa
2 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -31,7 +31,7 @@ Examples:
|![](https://badgen.now.sh/badge/build/passing) | https://badgen.now.sh/badge/build/passing |
|![](https://badgen.now.sh/badge/style/standard/f2a) | https://badgen.now.sh/badge/style/standard/f2a |
|![](https://badgen.now.sh/badge/license/Apache-2.0/blue) | https://badgen.now.sh/badge/license/Apache-2.0/blue |
|![](https://badgen.now.sh/badge/platform/ios%20%7C%20osx%20%7C%20tvos/grey) | https://badgen.now.sh/badge/platform/ios%20%7C%20osx%20%7C%20tvos/grey |
|![](https://badgen.now.sh/list/platform/ios,macos,tvos/grey) | https://badgen.now.sh/list/platform/ios,macos,tvos/grey |
### Programmatically

Wyświetl plik

@ -18,6 +18,11 @@ function serveBadge (req, res, params) {
}
}
function serveListBadge (req, res, params) {
const { subject, status, color } = params
serveBadge(req, res, { subject, status: status.replace(/,/g, ' | '), color })
}
function redirect (req, res) {
res.writeHead(302, { 'Location': 'https://amio.github.io/badgen' })
res.end()
@ -25,6 +30,8 @@ function redirect (req, res) {
router.get('/badge/:subject/:status', serveBadge)
router.get('/badge/:subject/:status/:color', serveBadge)
router.get('/list/:subject/:status', serveListBadge)
router.get('/list/:subject/:status/:color', serveListBadge)
router.get('/', redirect)
const server = http.createServer((req, res) => router.lookup(req, res))