{"size": 3103, "ext": "scrbl", "max_stars_repo_path": "web-server-doc/web-server/scribblings/web-server-unit.scrbl", "max_stars_repo_name": "jessealama/web-server", "max_stars_repo_stars_event_min_datetime": "2015-01-21T08:11:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T08:28:39.000Z", "max_issues_repo_path": "web-server-doc/web-server/scribblings/web-server-unit.scrbl", "max_issues_repo_name": "jessealama/web-server", "max_issues_repo_issues_event_min_datetime": "2015-01-14T08:06:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T14:38:40.000Z", "max_forks_repo_path": "web-server-doc/web-server/scribblings/web-server-unit.scrbl", "max_forks_repo_name": "jessealama/web-server", "max_forks_repo_forks_event_min_datetime": "2015-03-05T15:07:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-30T18:59:25.000Z"}
{"max_stars_count": 82, "max_issues_count": 105, "max_forks_count": 37, "avg_line_length": 36.5058823529, "max_line_length": 88, "alphanum_fraction": 0.6300354496}
#lang scribble/doc
@(require "web-server.rkt")

@title[#:tag "web-server-unit"]{Server Units}
@(require (for-label web-server/web-server-sig
                     web-server/web-server-unit
                     racket/async-channel
                     racket/tcp
                     net/tcp-sig
                     web-server/private/dispatch-server-sig
                     web-server/private/dispatch-server-unit
                     web-server/dispatchers/dispatch
                     web-server/web-config-sig
                     web-server/web-config-unit
                     web-server/web-server))

@section[#:tag "ws-sig" #:style 'hidden]{Signature}

@defmodule[web-server/web-server-sig]{

@defsignature[web-server^ ()]{

 @defproc[(serve [#:confirmation-channel confirmation-ach
                  (or/c #f (async-channel/c
                            (or/c exn? port-number?)))
                  #f])
          (-> any)]{
   The same as @sigelem[dispatch-server^ serve] from @racket[dispatch-server^].
   The @racket[dispatch-server^] signature is an alias for
   @racket[web-server^].
 }

 @defproc[(serve-ports [ip input-port?]
                       [op output-port?])
          any]{
 Asynchronously serves a single connection represented by the ports @racket[ip] and
 @racket[op].
 }
}

}

@section[#:tag "ws-unit" #:style 'hidden]{Unit}

@defmodule[web-server/web-server-unit]

@defthing[web-server-with-connect@ (unit/c (web-config*^ tcp^ dispatch-server-connect^)
                                           (web-server^))]{

Uses the @racket[web-config*^] to construct a @racket[dispatcher/c]
function that sets up one virtual host dispatcher, for each virtual
host in the @racket[web-config*^], that sequences the following
operations:

@itemize[
 @item{Logs the incoming request with the given format to the given file}
 @item{Performs HTTP Basic Authentication with the given password file}
 @item{Allows the @racket["/conf/refresh-passwords"] URL to refresh the password file.}
 @item{Allows the @racket["/conf/collect-garbage"] URL to call the garbage collector.}
 @item{Allows the @racket["/conf/refresh-servlets"] URL to refresh the servlets cache.}
 @item{Executes servlets mapping URLs to the given servlet root directory under htdocs.}
 @item{Serves files under the @racket["/"] URL in the given htdocs directory.}
]

 Using this @racket[dispatcher/c], it loads a dispatching server that provides
 @sigelem[web-server^ serve] and @sigelem[web-server^ serve-ports] functions
 that operate as expected.

 @history[#:added "1.1"
          #:changed "1.6"
          @elem{Use @racket[web-config*^] rather than @racket[web-config^].
            See @elemref["safety-limits-porting"]{compatability note}.}]
}


@defthing[web-server@ (unit/c (web-config*^ tcp^)
                              (web-server^))]{

Like @racket[web-server-with-connect@], but using @racket[raw:dispatch-server-connect@].

 @history[#:changed "1.6"
          @elem{Use @racket[web-config*^] rather than @racket[web-config^].
            See @elemref["safety-limits-porting"]{compatability note}.}]
}
