Changing web server default servlet handling

svn: r12178
This commit is contained in:
Jay McCarthy 2008-10-30 14:34:21 +00:00
parent 109be3ebf1
commit fc64cf2b77
22 changed files with 43 additions and 33 deletions

View File

@ -27,7 +27,7 @@
d)
(define example-servlets
(build-path (collection-path "web-server") "default-web-root" "servlets" "examples/"))
(build-path (collection-path "web-server") "default-web-root" "htdocs" "servlets" "examples/"))
(define dispatch-servlets-tests
(test-suite

View File

@ -15,7 +15,7 @@
;; Configuration
(define *data-file*
(build-path (collection-path "web-server")
"default-web-root" "servlets" "examples" "english-measure-questions.ss"))
"default-web-root" "htdocs" "servlets" "examples" "english-measure-questions.ss"))
(define *questions-per-quiz* 5)
(require web-server/servlet

View File

@ -113,7 +113,6 @@ structures.
where a @scheme[host-table-sexpr] is:
@; XXX Allowable log-formats?
@; XXX Where the paths are resolved relative to
@schemeblock[
`(host-table
@ -142,6 +141,12 @@ where a @scheme[host-table-sexpr] is:
(mime-types ,path-string?)
(password-authentication ,path-string?)))]
@(require (for-label web-server/dispatchers/dispatch-log))
Allowable @scheme['log-format]s are those accepted by @scheme[log-format->format].
Note: You almost always want to leave everything in the @scheme['paths] section the default except the @scheme['host-root].
@defproc[(read-configuration-table (path path-string?))
configuration-table?]{
This function reads a @scheme[configuration-table] from @scheme[path].

View File

@ -187,25 +187,31 @@ a URL that refreshes the password file, servlet cache, etc.}
@defthing[paren-format format-req/c]{
Formats a request by:
@schemeblock[
(format "~s~n"
(list 'from (request-client-ip req)
'to (request-host-ip req)
'for (url->string (request-uri req)) 'at
(date->string (seconds->date (current-seconds)) #t)))
]}
(format
"~s~n"
(list 'from (request-client-ip req)
'to (request-host-ip req)
'for (url->string (request-uri req)) 'at
(date->string
(seconds->date (current-seconds)) #t)))
]}
@defthing[extended-format format-req/c]{
Formats a request by:
@schemeblock[
(format "~s~n"
`((client-ip ,(request-client-ip req))
(host-ip ,(request-host-ip req))
(referer ,(let ([R (headers-assq* #"Referer" (request-headers/raw req))])
(if R
(header-value R)
#f)))
(uri ,(url->string (request-uri req)))
(time ,(current-seconds))))
(format
"~s~n"
`((client-ip ,(request-client-ip req))
(host-ip ,(request-host-ip req))
(referer
,(let ([R (headers-assq*
#"Referer"
(request-headers/raw req))])
(if R
(header-value R)
#f)))
(uri ,(url->string (request-uri req)))
(time ,(current-seconds))))
]}
@defthing[apache-default-format format-req/c]{

View File

@ -43,7 +43,7 @@ operations:
@item{Allows the @scheme["/conf/refresh-passwords"] URL to refresh the password file.}
@item{Allows the @scheme["/conf/collect-garbage"] URL to call the garbage collector.}
@item{Allows the @scheme["/conf/refresh-servlets"] URL to refresh the servlets cache.}
@item{Execute servlets under the @scheme["/servlets/"] URL in the given servlet root directory.}
@item{Execute servlets in the mapping URLs to the given servlet root directory.}
@item{Serves files under the @scheme["/"] URL in the given htdocs directory.}
]

View File

@ -15,14 +15,14 @@
(#:port (or/c false/c number?)
#:listen-ip (or/c false/c string?)
#:make-servlet-namespace make-servlet-namespace/c)
unit?)]
unit?)]
[configuration-table-sexpr->web-config@
(->* (list?) ; XXX
(#:web-server-root path-string?
#:port (or/c false/c number?)
#:listen-ip (or/c false/c string?)
#:make-servlet-namespace make-servlet-namespace/c)
unit?)])
(#:web-server-root path-string?
#:port (or/c false/c number?)
#:listen-ip (or/c false/c string?)
#:make-servlet-namespace make-servlet-namespace/c)
unit?)])
; configuration-table->web-config@ : path -> configuration
(define (configuration-table->web-config@
@ -121,12 +121,13 @@
(if p
(build-path-unless-absolute b p)
#f))])
(let ([host-base (build-path-unless-absolute web-server-root (paths-host-base paths))])
(let* ([host-base (build-path-unless-absolute web-server-root (paths-host-base paths))]
[htdocs-base (build-path-unless-absolute host-base (paths-htdocs paths))])
(make-paths (build-path-unless-absolute host-base (paths-conf paths))
host-base
(build-path-unless-absolute host-base (paths-log paths))
(build-path-unless-absolute host-base (paths-htdocs paths))
(build-path-unless-absolute host-base (paths-servlet paths))
htdocs-base
(build-path-unless-absolute htdocs-base (paths-servlet paths))
(build-path-unless-absolute host-base (paths-mime-types paths))
(build-path-unless-absolute host-base (paths-passwords paths))))))

View File

@ -85,11 +85,9 @@
(lambda _
(clear-cache!)
((responders-servlets-refreshed (host-responders host-info)))))
(filter:make
#rx"^/servlets"
(sequencer:make
(timeout:make (timeouts-servlet-connection (host-timeouts host-info)))
servlet-dispatch))))
(sequencer:make
(timeout:make (timeouts-servlet-connection (host-timeouts host-info)))
servlet-dispatch)))
(files:make #:url->path (fsmap:make-url->path (paths-htdocs (host-paths host-info)))
#:path->mime-type (make-path->mime-type (paths-mime-types (host-paths host-info)))
#:indices (host-indices host-info))