Regular expressions

Imported Google Group message. Original thread at: Redirecting to Google Groups Import Date: 2016-01-19 21:11:15 +0000.
Sender:Miii Eeee.
Date:Tuesday, 5 May 2015 14:50:19 UTC+1.

Hi,

When defining paths in the endpoint designer is it possible to have regular expressions on them?

In my api there are urls I have to hit that have the following format:

http://mybackend.org/api/users/{userid}/settings

It would be helpful if I could define a white listed path the following way

http://mybackend.org/api/users/(\d+)/settings

Thanks,

M

Imported Google Group message.
Sender:Martin Buhr.
Date:Tuesday, 5 May 2015 15:07:28 UTC+1.

Hi,

Regexes are not directly supported (so (\d+) won’t work), however we do have a placeholder syntax in the path definitions so you can match dynamic paths. this was going to be made more verbose in later versions (e.g. named variables), but we haven’t got round to it yet.

In fact, the first form you’ve put is valid, so if you define a path as:

users/{uid}/settings

Tyk will convert this to:

users/(.*?)/settings

thanks,
Martin

  • show quoted text -