[racket] send/suspend outside #lang web-server

From: Veer (diggerrrrr at gmail.com)
Date: Mon Sep 5 02:44:25 EDT 2011

Can I use send/suspend  outside the #lang web-server module ?
For example , the two modules  below don't work , I get something like :
"Attempt to capture a continuation from within an unsafe context: ...."

For statefull servlets this type of example works fine.

"Module test.rkt"
#lang web-server
(require web-server/servlet-env)
(require "something.rkt")

(define (start request)
  (show request))

(define (show request)

  (define (gen-resp make-url)
     `(html (body (h1 "testing")
                  (a ((href ,(make-url do-something))) "do something")))))

  (define (do-something request)

    (define something (get-something))

      [(request? something) (error 'no-good)]
      [else (error 'ok "~a" something)]))

  (send/suspend/dispatch gen-resp))

(serve/servlet  start #:stateless? #t )

"Module something.rkt"
#lang racket
(require web-server/lang/web)
(require web-server/http/xexpr)

(provide get-something)

(define (get-something)

  (define  req
     (lambda (make-url)
        `(html (body (h1 "something")
                     (a ((href ,make-url)) "try something")))))))

  (printf "why are we not here\n")

Posted on the users mailing list.