[ 
https://issues.apache.org/jira/browse/COUCHDB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13052798#comment-13052798
 ] 

Markus Barchfeld commented on COUCHDB-1017:
-------------------------------------------

Thanks for your comment, Gabriel. It made me look into #1074, where everything 
is explained.

My use case was to rewrite an URL with year and month into startkey and endkey 
parameters.
E.g the incoming URL

"availabledays/2010/1" 

with the rewrite rule 

    {
      "from": "/availabledays/:year/:month",
      "to": "_list/available/measurements",
      "query": {
        "group_level": "3",
        "startkey": [ ":year", ":month" ],
        "endkey": [ ":year",":month", {}] 
       },
       "formats": {
            "year": "int",
            "month": "int"
       }
    },

is transformed into

_list/available/measurements?startkey=%5B2010%2C1%5D&endkey=%5B2010%2C1%2C%7B%7D%5D&group_level=3&year=2010&month=1

Which is perfect. Or at least nearly ;-) Any way to get rid of the year and 
month query parameters in the rewritten rule?


> HTTP Rewrite Handler: Rewriting strings in queries
> --------------------------------------------------
>
>                 Key: COUCHDB-1017
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1017
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: HTTP Interface
>    Affects Versions: 1.0.1
>            Reporter: Michel Legnered
>            Assignee: Benoit Chesneau
>            Priority: Minor
>
> I have this rewrite:
> {
>       "from": "/u/:key",
>       "to": "_list/pouch/user-items",
>       "method": "GET",
>       "query": {"key": ":key"}
> }
> ..where the view returns: {"error":"bad_request","reason":"invalid UTF-8 
> JSON"}. The view query looks like this ?key=somekey, but for the view to 
> succeed "somekey" need to be in double quotes.
> Maybe one could improve the rewriter's behavior for rewriting strings in 
> queries? 
> Here is one workaround:
> {
>       "from": "/u/:startkey",
>       "to": "_list/pouch/user-items",
>       "method": "GET",
>       "query": {
>               "startkey": [":startkey"],
>               "endkey": [":startkey", {}]
>       }
> },

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to