You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Scott Weber <sc...@sbcglobal.net> on 2014/01/31 19:30:37 UTC

API to Update httpd_db_handlers in Config

How does one perform am API based update to the "httpd_db_handlers" section of the config.


Given something like this:


[httpd_db_handlers]
_my_function = {couch_httpd_external, handle_external_req, <<"my_function">>}

I try to update it with:

  couchSend( "PUT /_config/httpd_db_handlers/_my_function", 

     "{couch_httpd_external, handle_external_req, <<\"my_functioni\"\>>}" );

If failing with a "invalid JSON"...  Which I can see that it is.
It logs  "lexical error: invalid char in json text.\n"}},  But doesn't tell me which character it doesn't like.


However, I was able to update something else like this:

     couchSend( "PUT /_config/log/include_sasl", 

      "\"false\"" );

And it works fine.

Without wasting a bunch of bandwidth telling ALL the different ways I have tried to escape the quotes, added extra quotes, encoded angle brackets, braces, tried using text/plain, text/html, etc... (or tell my boss how much it cost him while I am trying all different these ways, and doing web searches)  I figure I'll just give up and ask.  :-)


How does one encode the following string for an API based config update?

    {couch_httpd_external, handle_external_req, <<"my_function">>}

Thanks.
-Scott

Re: API to Update httpd_db_handlers in Config

Posted by Scott Weber <sc...@sbcglobal.net>.
That was one iteration I missed.  It worked.  Thanks.

The extra backslash was my edit error in the email.  Striping out internal function names.


"\{couch_httpd_external, handle_external_req, <<'my_function'>>\}"
"\"{couch_httpd_external, handle_external_req, <<'my_function'>>\}\""
"{couch_httpd_external, handle_external_req, \<\<'my_function'\>\>}"
"\{couch_httpd_external, handle_external_req, <<\"my_function\">>\}"
'"couch_httpd_external, handle_external_req, %3C%3C%22my_function%22%3E%3E"'

Just to name a few.




________________________________
 From: muji <fr...@gmail.com>
To: user@couchdb.apache.org; Scott Weber <sc...@sbcglobal.net> 
Sent: Friday, January 31, 2014 1:09 PM
Subject: Re: API to Update httpd_db_handlers in Config
 

I think the additional backslash before the > is causing the problem, try:

"{couch_httpd_external, handle_external_req, <<\"my_function\">>}"

This works for me:

echo '"{couch_httpd_external, handle_external_req, <<\"my_function\">>}"' |
jsonlint

Whilst:

echo '"{couch_httpd_external, handle_external_req, <<\"my_function\"\>>}"'
| jsonlint

Fails.


On 1 February 2014 02:30, Scott Weber <sc...@sbcglobal.net> wrote:

> How does one perform am API based update to the "httpd_db_handlers"
> section of the config.
>
>
> Given something like this:
>
>
> [httpd_db_handlers]
> _my_function = {couch_httpd_external, handle_external_req,
> <<"my_function">>}
>
> I try to update it with:
>
>   couchSend( "PUT /_config/httpd_db_handlers/_my_function",
>
>      "{couch_httpd_external, handle_external_req, <<\"my_functioni\"\>>}"
> );
>
> If failing with a "invalid JSON"...  Which I can see that it is.
> It logs  "lexical error: invalid char in json text.\n"}},  But doesn't
> tell me which character it doesn't like.
>
>
> However, I was able to update something else like this:
>
>      couchSend( "PUT /_config/log/include_sasl",
>
>       "\"false\"" );
>
> And it works fine.
>
> Without wasting a bunch of bandwidth telling ALL the different ways I have
> tried to escape the quotes, added extra quotes, encoded angle brackets,
> braces, tried using text/plain, text/html, etc... (or tell my boss how much
> it cost him while I am trying all different these ways, and doing web
> searches)  I figure I'll just give up and ask.  :-)
>
>
> How does one encode the following string for an API based config update?
>
>     {couch_httpd_external, handle_external_req, <<"my_function">>}
>
> Thanks.
> -Scott
>



-- 
mischa (aka muji).

Re: API to Update httpd_db_handlers in Config

Posted by muji <fr...@gmail.com>.
I think the additional backslash before the > is causing the problem, try:

"{couch_httpd_external, handle_external_req, <<\"my_function\">>}"

This works for me:

echo '"{couch_httpd_external, handle_external_req, <<\"my_function\">>}"' |
jsonlint

Whilst:

echo '"{couch_httpd_external, handle_external_req, <<\"my_function\"\>>}"'
| jsonlint

Fails.


On 1 February 2014 02:30, Scott Weber <sc...@sbcglobal.net> wrote:

> How does one perform am API based update to the "httpd_db_handlers"
> section of the config.
>
>
> Given something like this:
>
>
> [httpd_db_handlers]
> _my_function = {couch_httpd_external, handle_external_req,
> <<"my_function">>}
>
> I try to update it with:
>
>   couchSend( "PUT /_config/httpd_db_handlers/_my_function",
>
>      "{couch_httpd_external, handle_external_req, <<\"my_functioni\"\>>}"
> );
>
> If failing with a "invalid JSON"...  Which I can see that it is.
> It logs  "lexical error: invalid char in json text.\n"}},  But doesn't
> tell me which character it doesn't like.
>
>
> However, I was able to update something else like this:
>
>      couchSend( "PUT /_config/log/include_sasl",
>
>       "\"false\"" );
>
> And it works fine.
>
> Without wasting a bunch of bandwidth telling ALL the different ways I have
> tried to escape the quotes, added extra quotes, encoded angle brackets,
> braces, tried using text/plain, text/html, etc... (or tell my boss how much
> it cost him while I am trying all different these ways, and doing web
> searches)  I figure I'll just give up and ask.  :-)
>
>
> How does one encode the following string for an API based config update?
>
>     {couch_httpd_external, handle_external_req, <<"my_function">>}
>
> Thanks.
> -Scott
>



-- 
mischa (aka muji).