AtlatestRepositorysigil-http

sigil-http / tree / test / integrationintegration-server.sgl

1;;; Test server for integration tests
2;;; Listens on port specified as first argument (default 8099)
3
4(import (sigil http server)
5 (sigil http request)
6 (sigil http response))
7
8(define (handler request)
9 (let ((path (http-request-path request))
10 (body (http-request-body request)))
11 (cond
12 ((string=? path "/echo-body")
13 (http-response/text HTTP-OK (or body "(no body)")))
14 ((string=? path "/hello")
15 (http-response/text HTTP-OK "Hello, World!"))
16 (else
17 (http-response/not-found)))))
19;; Use port 8099 for testing
20(http-serve handler port: 8099)