# Lambda functions with dynamic path

**URL:** <https://answers.netlify.com/t/lambda-functions-with-dynamic-path/6356>\
**Category:** Support\
**Tags:** lambda-functions, redirects\
**Created:** [December 17, 2019, 9:27pm UTC](https://answers.netlify.com/t/lambda-functions-with-dynamic-path/6356 "2019-12-17T21:27:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alecdotninja](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/alecdotninja/32/4956_2.png) [@alecdotninja](https://answers.netlify.com/u/alecdotninja)\
**Post date:** [December 17, 2019, 9:27pm UTC](https://answers.netlify.com/t/lambda-functions-with-dynamic-path/6356/1 "2019-12-17T21:27:50Z")

</div>

Hello! 👋

I have been working on [a small project to display a build matrix for TravisCI](https://github.com/alecdotninja/travis-matrix-badge) using Netlify functions. I have a basic version working, but it has a super clunky API with a couple of required query parameters. I would like to clean this up a bit by moving those required parameters to path segments (e.g. `/:owner/:repo/badge-v1.svg` instead of `/badge-v1.svg?owner=:owner&repo=:repo`).

I have tried something like this (to no avail):

```plaintext
[[redirects]]
	from = "/:owner/:repo/badge-v1.svg"
	to = "/.netlify/functions/badge-v1"
	query = { owner = ":owner", repo = ":repo" }
	status = 200

```

Is there a way to accomplish this with rewrites?

Thanks!

---

<div class="post-metadata">

**Author:** ![Dennis](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/dennis/32/34_2.png) [@Dennis](https://answers.netlify.com/u/Dennis)\
**Post date:** [December 19, 2019, 2:09pm UTC](https://answers.netlify.com/t/lambda-functions-with-dynamic-path/6356/2 "2019-12-19T14:09:33Z")

</div>

You probably also need to define the params in your `to` attribute. Like so:

```auto
to = "/.netlify/functions/badge-v1?owner=:owner&repo=:repo"

```

It’s illustrated [here](https://docs.netlify.com/routing/redirects/redirect-options/#query-parameters) in the \_redirects format.

---

<div class="post-metadata">

**Author:** ![alecdotninja](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/alecdotninja/32/4956_2.png) [@alecdotninja](https://answers.netlify.com/u/alecdotninja)\
**Post date:** [January 3, 2020, 6:57pm UTC](https://answers.netlify.com/t/lambda-functions-with-dynamic-path/6356/3 "2020-01-03T18:57:07Z")

</div>

In case anyone else stumbles across this, I was able to get the interface I wanted.

It turns out that Netlify Functions see _the original url and params_ when accessed via a rewrite (not the rewritten one), so there is no need to fiddle with getting path segments into the params at all.

You can see the working `_redirects` file [here](https://github.com/alecdotninja/travis-matrix-badge/blob/master/_redirects).

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [January 9, 2020, 5:24pm UTC](https://answers.netlify.com/t/lambda-functions-with-dynamic-path/6356/4 "2020-01-09T17:24:31Z")

</div>

thanks for sharing 🙏
