kopia lustrzana https://github.com/badgen/badgen
Add /list/ routes to service
rodzic
b6014b1d22
commit
f40f21eeaa
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
Ładowanie…
Reference in New Issue