artanis
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Artanis] accept POST in "application" mode


From: Julio Claudio Matus Ramirez
Subject: Re: [Artanis] accept POST in "application" mode
Date: Mon, 10 Sep 2018 21:55:56 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Helo Nala,

(1)

> To be clarified, use (http-method "/your_prefer_url" handler) is not
> "script mode" only, it could appear in "application mode" (yes, MVC).
> The controller is defined as GET in default.

Ah, I see.
So, by default, when you make a new "controller" in MVC mode, the
controller code file has some default functions as templates, in the format
"(<controller>-define <view> ...)", which is kind of equivalent to
"(get "/<controller>/<view>" ...)".
And the default template only works for GET requests, and nothing else.
Right?

At least that's what I see testing so far.

(2)
So, I added in the controller file something like:
"(post "/<controller>/<view>" ...)"
And I confirmed now it doesn't give me errors when I send post requests,
yay.
However, now my
  (get-from-qstr rc "some-varname")
code doesn't work. (it's blank)
Apparently, I can see the POST string in the body part. So I can
actually see what I posted with:
  (utf8->string (rc-body rc))

# above being done after loading the module "rnrs bytevectors"

But, I can't parse that string with get-from-qstr, it's just a string
that looks like "name=value&".

Is this expected behaviour? Or am I missing a function/doing something wrong?


Cheers,


Nala Ginrut <address@hidden> writes:

> Hi Julio!
>
> Julio Claudio Matus Ramirez writes:
>
>> Hello.
>>
>> I'm using artanis in "application mode" (with art work, not running from
>> a script-like single file, I think you call that "script mode").
>>
>> I see from the documentation that to accept data from POST requests, in
>> script mode, you have to define a router with the method "post" for the path
>> in question.
>> I can't find in the documentation how to make that for an application made
>> with "art".
>>
>> Can you tell me how to define a path (controller/view) in which I can
>> use POST data?
>
> I think you mean that you can't define a POST controller by the
> controller define helper function. For this purpose, you should use
> (get "/your_prefer_url" handler)
>
> To be clarified, use (http-method "/your_prefer_url" handler) is not
> "script mode" only, it could appear in "application mode" (yes, MVC).
> The controller is defined as GET in default.
>
>>
>> P.S.
>> I see there's a ".route" file in the application dir that might be
>> related, but I tried changing it and it gets overwritten. It'd be nice
>> to have documented its purpose too. If you tell me I'll add it to the
>> manuals.
>
> The route module is still suspended since I've always been blocking by
> other higher priority tasks, file descriptors leaking, more efficient URL 
> remapping, websocket, etc...
>
> For now, you may just simply ignore the .route file.
> If you just want to handle RESTful APIs, the advanced route mapping is 
> unecessary for
> simple cases.
>
> --
> GNU Powered it
> GPL Protected it
> GOD Blessed it
> HFG - NalaGinrut
> Fingerprint F53B 4C56 95B5 E4D5 6093 4324 8469 6772 846A 0058
>

-- 
diaspora: sysad.org/u/rikijpn
GPG key: http://pgp.mit.edu/pks/lookup?op=get&search=0x280640B9A94C170D



reply via email to

[Prev in Thread] Current Thread [Next in Thread]