Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP routing issues #1332

Merged
merged 2 commits into from May 22, 2019
Merged

Fix HTTP routing issues #1332

merged 2 commits into from May 22, 2019

Conversation

samtstern
Copy link
Contributor

@samtstern samtstern commented May 22, 2019

Fixes #1325 (some HTTP methods blocked)
Fixes #1314 (query params lost)

Tested with this simple function:

exports.httpFn = functions.https.onRequest((request, response) => {
    response.send({
        method: request.method,
        path: request.path, 
        query: request.query 
    });
});

Simple GET request

$ http -b GET http://localhost:5001/fir-dumpster/us-central1/httpFn
{
    "method": "GET",
    "path": "/",
    "query": {}
}

Simple DELETE request:

$ http -b DELETE http://localhost:5001/fir-dumpster/us-central1/httpFn
{
    "method": "DELETE",
    "path": "/",
    "query": {}
}

GET with query params:

$ http -b GET "http://localhost:5001/fir-dumpster/us-central1/httpFn?foo=bar&baz=qux"
{
    "method": "GET",
    "path": "/",
    "query": {
        "baz": "qux",
        "foo": "bar"
    }
}

GET with query params at subpath:

$ http -b GET "http://localhost:5001/fir-dumpster/us-central1/httpFn/subpath?foo=bar&baz=qux"
{
    "method": "GET",
    "path": "/subpath",
    "query": {
        "baz": "qux",
        "foo": "bar"
    }
}

@samtstern samtstern requested a review from abeisgoat May 22, 2019 16:57
hub.post(httpsFunctionRoutes, httpsHandler);
hub.get(httpsFunctionRoutes, httpsHandler);

hub.all(httpsFunctionRoutes, httpsHandler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had no idea this existed, dope.

@@ -93,4 +94,24 @@ describe("FunctionsEmulatorUtils", () => {
expect(trimSlashes("///a////b//c/")).to.equal("a/b/c");
});
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests 🙏

@googlebot googlebot added the cla: yes Manual indication that this has passed CLA. label May 22, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 62.099% when pulling 39fda53 on ss-fix-http-routing into 30e6d6f on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 62.099% when pulling 39fda53 on ss-fix-http-routing into 30e6d6f on master.

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
4 participants