You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Wordit <wo...@gmail.com> on 2013/02/09 06:20:43 UTC

Passing parameters in simple URLs

I'd like to pass a few parameters via an app's url without using the
server-side style "?param1=a&param2=b".
Instead, I'd like to use segments like this
"../database/index.html/a/b". I tried adding a hashtag
".../index.html/#/a/b", but couchdb didn't like that at all.

I can process the url with javascript. Where I'm stuck is preventing
couchdb from processing the url after the index.html section.

What alternatives are there to pass params in simple urls? Are there
any rewrite rules which may help?

Thanks,

Marcus

Re: Passing parameters in simple URLs

Posted by Wordit <wo...@gmail.com>.
Benoit,

I tried your suggestion but it doesn't seem to be working or am I
entering the wrong URL? The home url is: .../_design/mydb/index.html

When I query: .../_design/mydb/a/b
I get: {"error":"not_found","reason":"Document is missing attachment"}

My goal is to generate simple urls for users instead of server-side
params with: ?foo=a&bar=b

Thanks,

Marcus



On Sat, Feb 9, 2013 at 8:44 AM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Feb 9, 2013 6:21 AM, "Wordit" <wo...@gmail.com> wrote:
>>
>> I'd like to pass a few parameters via an app's url without using the
>> server-side style "?param1=a&param2=b".
>> Instead, I'd like to use segments like this
>> "../database/index.html/a/b". I tried adding a hashtag
>> ".../index.html/#/a/b", but couchdb didn't like that at all.
>>
>> I can process the url with javascript. Where I'm stuck is preventing
>> couchdb from processing the url after the index.html section.
>>
>> What alternatives are there to pass params in simple urls? Are there
>> any rewrite rules which may help?
>>
>> Thanks,
>>
>> Marcus
> Not sure if it's what you want but you can use a rewrite rule:
>
> {"from": "/:a/:b/", "to": "index.html"}
>
> a and b will be passed as query parameters to the index  while the user
> will query /a/b.
>
> - benoît

Re: Passing parameters in simple URLs

Posted by Benoit Chesneau <bc...@gmail.com>.
On Feb 9, 2013 6:21 AM, "Wordit" <wo...@gmail.com> wrote:
>
> I'd like to pass a few parameters via an app's url without using the
> server-side style "?param1=a&param2=b".
> Instead, I'd like to use segments like this
> "../database/index.html/a/b". I tried adding a hashtag
> ".../index.html/#/a/b", but couchdb didn't like that at all.
>
> I can process the url with javascript. Where I'm stuck is preventing
> couchdb from processing the url after the index.html section.
>
> What alternatives are there to pass params in simple urls? Are there
> any rewrite rules which may help?
>
> Thanks,
>
> Marcus
Not sure if it's what you want but you can use a rewrite rule:

{"from": "/:a/:b/", "to": "index.html"}

a and b will be passed as query parameters to the index  while the user
will query /a/b.

- benoît