At Tue, 28 Sep 2010 19:36:32 +0200, Peter Bex wrote: > > I was heavily using the http egg in chicken3, which is > > incompatible with chicken4. > > Unfortunately, it is. I like to think it's an improvement though :)
Yeah, I see that. It's clean. > > In chicken3/http-server, I did something like: > > (http:request-method-handler 'GET (lambda (req) ... > > This is converted like the following in chicken4/spiffy. > > (define (my-request-handler) > > (let* ([req (current-request)] > > [method (request-method req)]) > > (case method > > ((GET) (lambda (req) ...) > > ((POST) (lambda (req) ...) > > (vhost-map `((".*" . > > ,(lambda (continue) > > (my-request-handler))))) > > Yes, this is uglier. There are several different request handling > eggs now though! They make it easier to handle incoming requests. Is it that ugly? None of the request handling eggs in the spiffy manual was not so low level. > Porting the old-style request handling stuff shouldn't be too hard, > but I left it out because the way the old code worked is incompatible > with vhost support. The new Spiffy has vhost support built in from > day 1. Felix isn't happy about this change either, so you would > probably make him very happy by making an egg that emulates the old > API :) I don't understand the discussion here. How felix isn't happy? I thought the vhost support is very powerful. (But, at the first look, I did't know how I could emulate low-level request handler.) > > There were many tiny things for porting my code, such as dealing > > with the fancy uri-common egg and string-match -> string-search. > > Are you using "fancy" in a good way or in a bad way? I'm really eager > to hear how these new http libraries are being used and how people like > them, so I can improve where things are not as smooth as they should be. Good question. I used "fancy" in a good way, but if you ask me: it might be too premitive, or there are too many procedures to understand. My code was (since it was from chicken3) based on the string-based representation of URLs, hence I made some util functions as follows: (define (get-path-from-uri uri) (define len (- (string-length prefix) 1)) (let ([path (string-intersperse (cdr (uri-path uri)) "/")]) (and path (string-prefix? prefix path) (string-drop path len)))) (define (get-ref-url-from uri) (let ([baseuri (uri-reference (sprintf "~a://~a:~a/" (uri-scheme uri) (uri-host uri) (uri-port uri)))]) (uri->string (uri-relative-from uri baseuri)))) (define (get-query-from-uri uri) (let ([query (uri-query uri)]) (and (pair? query) (map (lambda (x) (cons (symbol->string (car x)) (cdr x))) query)))) Please let me know if there's a better way of doing it. > > Anyway it's nice to have it working, and > > I would like thank everyone contributing to chicken4! > > And I would like to thank you for switching and giving feedback! You are welcome. Best, Daishi _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users