Hi David,
On 4/23/2015 1:35 PM, David Vanderson wrote:
What I want to do is:
create a hash representing the return object
- data to return
- URL for next page function (if applicable)
- URL for prev page function (if applicable)
convert the hash to a jsexpr
send/suspend/dispatch the jsexpr
#lang web-server/insta
(require json)
(define (response/json jsexpr)
(response/full 200 #"Okay" (current-seconds) #"application/json"
(list)
(list #"" (jsexpr->bytes jsexpr))))
(define (start request)
(define idx 0) ; state stored in continuation
(define (show-prev-page request)
(set! idx (sub1 idx))
(show-page))
(define (show-next-page request)
(set! idx (add1 idx))
(show-page))
(define (show-page)
(send/suspend/dispatch
(lambda (embed/url)
; make hash representing the return object
(define js-hash (hasheq 'data idx
'url-next-page (embed/url show-next-page)
'url-prev-page (embed/url
show-prev-page)))
; send the response, a hasheq is already a jsexpr
(response/json js-hash))))
(show-page))
Does this do what you want?
Possibly. Sorry, I moved on to something else in the meantime and I
have to get back to this.
Is it required to use define or would let bound variables in start work
also?
George
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.