You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Taras Puchko <ta...@gmail.com> on 2010/09/07 18:05:00 UTC
Passing matrix parameters to show and list
Hello,
Does anyone know if it's possible to pass matrix parameters to show and list
functions?
I tried the following rewrite rule: {"from" : "myshow/:id/:extra", "to":
"_show/myshow/:id"}
_rewrite/myshow/myid/path;m1=v1;m2=v2
is translated to
_show/myshow/myid?id=myid&extra=path%3Bm1%3Dv1%3Bm2%3Dv2
so I have
req.query.extra == "path;m1=v1;m2=v2" and can parse it manually.
But if I use special characters things break, e.g. I want to pass "a;b=c" as
a value for m2:
_rewrite/myshow/myid/path;m1=v1;m2=a%3Bb%3Dc
is translated to
_show/myshow/myid?id=myid&extra=path%3Bm1%3Dv1%3Bm2%3Da%3Bb%3Dc
so I have
req.query.extra == "path;m1=v1;m2=a;b=c" and cannot parse it correctly.
Thanks,
Taras
Re: Passing matrix parameters to show and list
Posted by Taras Puchko <ta...@gmail.com>.
Thank you,
I just wanted to use matrix parameters [1] but query should work for me too.
[1] http://www.w3.org/DesignIssues/MatrixURIs.html
Cheers,
Taras
On Tue, Sep 7, 2010 at 7:11 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Sep 7, 2010 at 9:05 AM, Taras Puchko <ta...@gmail.com>
> wrote:
> > Hello,
> >
> > Does anyone know if it's possible to pass matrix parameters to show and
> list
> > functions?
> >
> > I tried the following rewrite rule: {"from" : "myshow/:id/:extra", "to":
> > "_show/myshow/:id"}
> >
> > _rewrite/myshow/myid/path;m1=v1;m2=v2
> > is translated to
> > _show/myshow/myid?id=myid&extra=path%3Bm1%3Dv1%3Bm2%3Dv2
> > so I have
> > req.query.extra == "path;m1=v1;m2=v2" and can parse it manually.
> >
> > But if I use special characters things break, e.g. I want to pass "a;b=c"
> as
> > a value for m2:
> >
> > _rewrite/myshow/myid/path;m1=v1;m2=a%3Bb%3Dc
> > is translated to
> > _show/myshow/myid?id=myid&extra=path%3Bm1%3Dv1%3Bm2%3Da%3Bb%3Dc
> > so I have
> > req.query.extra == "path;m1=v1;m2=a;b=c" and cannot parse it correctly.
> >
> > Thanks,
> > Taras
> >
> You can do :
>
> _rewrite/myshow/myid/path?m1=v1&m2="a;b=c"
>
> then req.query should be ok.
>
> - benoit
>
Re: Passing matrix parameters to show and list
Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Sep 7, 2010 at 9:05 AM, Taras Puchko <ta...@gmail.com> wrote:
> Hello,
>
> Does anyone know if it's possible to pass matrix parameters to show and list
> functions?
>
> I tried the following rewrite rule: {"from" : "myshow/:id/:extra", "to":
> "_show/myshow/:id"}
>
> _rewrite/myshow/myid/path;m1=v1;m2=v2
> is translated to
> _show/myshow/myid?id=myid&extra=path%3Bm1%3Dv1%3Bm2%3Dv2
> so I have
> req.query.extra == "path;m1=v1;m2=v2" and can parse it manually.
>
> But if I use special characters things break, e.g. I want to pass "a;b=c" as
> a value for m2:
>
> _rewrite/myshow/myid/path;m1=v1;m2=a%3Bb%3Dc
> is translated to
> _show/myshow/myid?id=myid&extra=path%3Bm1%3Dv1%3Bm2%3Da%3Bb%3Dc
> so I have
> req.query.extra == "path;m1=v1;m2=a;b=c" and cannot parse it correctly.
>
> Thanks,
> Taras
>
You can do :
_rewrite/myshow/myid/path?m1=v1&m2="a;b=c"
then req.query should be ok.
- benoit