instaservlet.ss
#lang scheme/base

(require (for-syntax scheme/base)
         mzlib/runtime-path
         (planet schematics/instaweb:3/instaweb)
         (planet schematics/instaweb:3/defaults)
         "servlet-shim.ss")

; Servlet ----------------------------------------

(define-runtime-path here ".")

(define servlet-shim (build-path here "servlet-shim.ss"))

; Go! --------------------------------------------

; (request -> response) -> void
(define (go! servlet
             #:port              [port              8765]
             #:listen-ip         [listen-ip         "127.0.0.1"]
             #:htdocs-path       [htdocs-path       default-htdocs-path]
             #:mime-types-path   [mime-types-path   default-mime-types-path]
             #:servlet-namespace [servlet-namespace default-servlet-namespace])
  (with-servlet-function servlet
    (instaweb #:port port
              #:listen-ip listen-ip
              #:htdocs-path htdocs-path
              #:mime-types-path mime-types-path
              #:servlet-path servlet-shim
              #:servlet-namespace (cons (path->string servlet-shim) servlet-namespace))))

; Provide statements -----------------------------

(provide go!)