start.ss
#lang scheme/base
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SHP: Hypertext Processor
;;
;; a PHP like web framework for PLT Scheme
;;
;; Bonzai Lab, LLC.  All rights reserved.
;;
;; Licensed under LGPL.
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; start.ss
;; a default way of starting an SHP server, which combines both servlet.ss + web.ss
;; yc 8/23/2009 - first version 
(require web-server/servlet-env
         mzlib/etc
         )

(require (only-in web-server/servlet current-servlet-continuation-expiration-handler)
         web-server/managers/lru
         web-server/http/request-structs
         web-server/dispatchers/dispatch
         net/url
         mzlib/etc
         "main.ss"
         )

(provide (all-defined-out))

(define interface-version 'v2)

(define manager
  (create-LRU-manager current-servlet-continuation-expiration-handler
                      60
                      3600
                      (lambda () #t)
                      #:initial-count 1 
                      #:inform-p (lambda _ (void))))

(define (start-shp-server! path 
                           #:htdocs (htdocs #f) 
                           #:port (port 8080)
                           #:default (default "index")
                           #:not-found (not-found #f)
                           #:required (required "/include/required")
                           #:topfilter (topfilter #f) 
                           #:chrome (chrome #f)) 
  (thread (lambda ()
            (serve/servlet (make-shp-handler path 
                                             #:default default
                                             #:not-found not-found 
                                             #:required required 
                                             #:topfilter topfilter
                                             #:chrome chrome
                                             #:htdocs htdocs) 
                           #:port port
                           #:servlet-path "/"
                           #:launch-browser? #f
                           #:listen-ip #f
                           #:servlet-namespace (list (path->string (this-expression-file-name)))
                           #:servlets-root path
                           #:servlet-regexp #px".*"
                           #:server-root-path path
                           #:extra-files-paths 
                           (list (cond ((not htdocs) 
                                        (build-path path 'up "file"))
                                       ((string? htdocs) (string->path htdocs))
                                       (else htdocs)))
                           ))))
 
#|
(start-shp-server! (build-path (this-expression-source-directory) "shp")
                   #:htdocs (build-path (this-expression-source-directory) "file")
                   #:chrome "/include/chrome")
;;|#

;; (run! 8080 (build-path (this-expression-source-directory) "file"))