Skip to content

Fix query params and regional routing in emulated HTTP functions - #3033

Merged
samtstern merged 6 commits into
masterfrom
ss-fix-3032
Jan 14, 2021
Merged

Fix query params and regional routing in emulated HTTP functions#3033
samtstern merged 6 commits into
masterfrom
ss-fix-3032

Conversation

@samtstern

@samtstern samtstern commented Jan 14, 2021

Copy link
Copy Markdown
Contributor

Description

Fixes #3031
Fixes #3032

Scenarios Tested

const functions = require("firebase-functions");
const express = require('express');

const server = express();
server.get('/', (req, res) => {
    res.send('lol!');
});

exports.helloWorld = functions.https.onRequest((req,res) => {
    res.json(req.query);
});

exports.api = functions.region('europe-west3').https.onRequest(server);

For #3032

$ http "http://localhost:5001/fir-dumpster/us-central1/helloWorld"
HTTP/1.1 200 OK
connection: keep-alive
content-length: 2
content-type: application/json; charset=utf-8
date: Thu, 14 Jan 2021 14:19:19 GMT
etag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
keep-alive: timeout=5
x-powered-by: Express

{}
$ http "http://localhost:5001/fir-dumpster/us-central1/helloWorld?id=ok"
HTTP/1.1 200 OK
connection: keep-alive
content-length: 11
content-type: application/json; charset=utf-8
date: Thu, 14 Jan 2021 14:19:09 GMT
etag: W/"b-O3GjgUzPF1NwRnSW+tWJECMBW0k"
keep-alive: timeout=5
x-powered-by: Express

{
    "id": "ok"
}
$ http "http://localhost:5001/fir-dumpster/us-central1/helloWorld/?id=ok"
HTTP/1.1 200 OK
connection: keep-alive
content-length: 11
content-type: application/json; charset=utf-8
date: Thu, 14 Jan 2021 14:19:02 GMT
etag: W/"b-O3GjgUzPF1NwRnSW+tWJECMBW0k"
keep-alive: timeout=5
x-powered-by: Express

{
    "id": "ok"
}
$ http "http://localhost:5001/fir-dumpster/us-central1/helloWorld/?foo=bar&baz=quz"
HTTP/1.1 200 OK
connection: keep-alive
content-length: 25
content-type: application/json; charset=utf-8
date: Thu, 14 Jan 2021 14:18:48 GMT
etag: W/"19-aJ5/6qdD+JUaYGoi+SY23wQdu+Y"
keep-alive: timeout=5
x-powered-by: Express

{
    "baz": "quz",
    "foo": "bar"
}

For #3031

$ http http://localhost:5001/fir-dumpster/europe-west3/api
HTTP/1.1 200 OK
connection: keep-alive
content-length: 4
content-type: text/html; charset=utf-8
date: Thu, 14 Jan 2021 15:25:01 GMT
etag: W/"4-aGtZBCd1zhmF98IwfKTshS0CjO4"
keep-alive: timeout=5
x-powered-by: Express

lol!

Sample Commands

N/A

@google-cla google-cla Bot added the cla: yes Manual indication that this has passed CLA. label Jan 14, 2021
@samtstern
samtstern requested a review from bkendall January 14, 2021 14:31
@coveralls

coveralls commented Jan 14, 2021

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.01%) to 65.538% when pulling dd15ae3 on ss-fix-3032 into b26aa46 on master.

@samtstern

Copy link
Copy Markdown
Contributor Author

@bkendall something is not right with Coveralls, I added a unit test and changed one line which is covered by that test and my coverage decreased?

@samtstern samtstern changed the title Fix query params in emulated HTTP functions Fix query params and regional routing in emulated HTTP functions Jan 14, 2021
@samtstern
samtstern merged commit 10524fc into master Jan 14, 2021
@bkendall
bkendall deleted the ss-fix-3032 branch August 4, 2021 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Manual indication that this has passed CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clound Functions Emulator Not handling query parameters for functions deployed locally. Firebase functions emulator ignores region

3 participants