Skip to content

Instantly share code, notes, and snippets.

@knksmith57
Created January 29, 2018 18:23
Show Gist options
  • Save knksmith57/7fc07b3bfb8edd7f995b3ce856b75fd4 to your computer and use it in GitHub Desktop.
Save knksmith57/7fc07b3bfb8edd7f995b3ce856b75fd4 to your computer and use it in GitHub Desktop.
'use strict'
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('index')
})
app.get('/foo', (req, res) => {
res.send('foo')
})
app.get('/bar', (req, res) => {
res.send('bar')
})
module.exports.handler = (req, res) => {
if (req.url === '') {
req.url = '/'
}
app.handle(req, res)
}
{
"dependencies": {
"express": "^4.16.2"
}
}
@knksmith57
Copy link
Author

❯ curl https://redacted.cloudfunctions.net/hello-world
index

❯ curl https://redacted.cloudfunctions.net/hello-world/
index

❯ curl https://redacted.cloudfunctions.net/hello-world/foo
foo

❯ curl https://redacted.cloudfunctions.net/hello-world/bar
bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment