PSPDFKit-labs / bypass

Bypass provides a quick way to create a custom plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests.
https://hex.pm/packages/bypass
MIT License
964 stars 111 forks source link

Parametric route #93

Closed Gigitsu closed 4 years ago

Gigitsu commented 4 years ago

This adds support for parameters in expectation url.

You can define expectation like this:

Bypass.expect_once(bypass, "GET", "/1.1/users/:user_id", fn conn ->
    user_id = Map.get(conn.params, "user_id)
    Plug.Conn.resp(conn, 200, ~s<{....}>)
end)

and the request client->get("http://localhost:8080/1.1/users/1234") will successfully match the expectation defined above.

ream88 commented 4 years ago

I like this, @MSch what do you think?