[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: http-request in a controller- is it possible?
From: |
Nala Ginrut |
Subject: |
Re: http-request in a controller- is it possible? |
Date: |
Fri, 04 Dec 2020 00:26:42 +0800 |
User-agent: |
mu4e 1.4.13; emacs 27.1 |
Hi Morimer!
In theory, the API of (web client) like http-get should work in Ragnarok.
Because Ragnaork based on suspendable-ports for co-routine, and when
suspendable-ports is enabled, all the I/O ports defined in Guile should
be affected to be non-blocking.
I'm not sure about http-request function, where did you find it?
Anyway, if you don't insist on non-blocking, you can use guile
server-core to avoid non-blocking issue:
------------------------cut-----------------------
art work -s guile
------------------------end-----------------------
Best regards.
Mortimer Cladwell writes:
> Hi,
> Given the controller:
>
> (register-define add
> (lambda (rc)
> (let* (
> ;;(btc-usd 18000)
> (btc-usd (string->number(receive (response-status response-body)
> (http-request "
> https://blockchain.info/q/24hrprice") response-body)))
> (btc-req (/ 5000 btc-usd))
> (currency-content (string-append " <option
> value=\"btc\">Bitcoin " (number->string btc-req) " BTC</option>)))
> (view-render "add" (the-environment)))
> ))
>
> If I navigate to http://127.0.0.1:3000/register/add the browser hangs and
> eventually times out.
>
> At the console:
> Ragnarok: continue request
> Error: (wrong-type-arg #f Wrong type (expecting ~A): ~S (resumable
> continuation #<vm-continuation 7f768042f930>) (#<vm-continuation
> 7f768042f930>))
> Ingore it to avoid Ragnarok crash.
> main-loop again
>
> If at the REPL I evaluate (string->number (receive (response-status
> response-body)
> (http-request "https://blockchain.info/q/24hrprice") response-body))
> I get a number e.g 18,123.45
>
> If I comment out (btc-usd (string->number(receive.... ) and uncomment
> (btc-usd 18000), the expected page is rendered properly.
>
> Is it possible to use (http-request... ) in a controller?
> If not is there a workaround?
> Thanks
> Mortimer
--
GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
Fingerprint F53B 4C56 95B5 E4D5 6093 4324 8469 6772 846A 0058
signature.asc
Description: PGP signature
- http-request in a controller- is it possible?, Mortimer Cladwell, 2020/12/03
- Re: http-request in a controller- is it possible?,
Nala Ginrut <=
- Re: http-request in a controller- is it possible?, Nala Ginrut, 2020/12/03
- Re: http-request in a controller- is it possible?, Nala Ginrut, 2020/12/03
- Re: http-request in a controller- is it possible?, Jaft, 2020/12/04
- Re: http-request in a controller- is it possible?, Nala Ginrut, 2020/12/04
- Re: http-request in a controller- is it possible?, Jaft, 2020/12/05
- Re: http-request in a controller- is it possible?, Nala Ginrut, 2020/12/05
- Re: http-request in a controller- is it possible?, Jaft, 2020/12/05
- Re: http-request in a controller- is it possible?, Nala Ginrut, 2020/12/06
- Re: http-request in a controller- is it possible?, Jaft, 2020/12/06
- Re: http-request in a controller- is it possible?, Nala Ginrut, 2020/12/07