{"size": 2884, "ext": "scrbl", "max_stars_repo_path": "web-server-doc/web-server/scribblings/lang-api.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/lang-api.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/lang-api.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": 34.3333333333, "max_line_length": 82, "alphanum_fraction": 0.7274618585}
#lang scribble/doc
@(require "web-server.rkt")

@title[#:tag "stateless"]{Stateless Servlets}

@defmodulelang*[(web-server/base web-server)]

@section[#:style 'hidden #:tag "stateless-example"]{Example}

A stateless servlet should @racket[provide] the following exports:

@(require (for-label web-server/http
                     racket/serialize
                     (except-in web-server/stuffers stuffer)
                     web-server/managers/none
                     (except-in web-server/managers/manager manager)
                     "dummy-stateless-servlet.rkt")) @; to give a binding context
@declare-exporting[#:use-sources (web-server/scribblings/dummy-stateless-servlet)]

@defthing[interface-version (one-of/c 'stateless)]{
 This indicates that the servlet is a stateless servlet.
}

@defthing[stuffer (stuffer/c serializable? bytes?)]{
 This is the @tech{stuffer} that will be used for the servlet.
      
 If it is not provided, it defaults to @racket[default-stuffer].
}

@defthing[manager manager?]{
 This is the @tech{manager} that will be used for the servlet.
      
 If it is not provided, it defaults to @racket[(create-none-manager #f)].
}

@defproc[(start [initial-request request?])
         response?]{
 This function is called when an instance of this servlet is started.
 The argument is the HTTP request that initiated the instance.
}

An example @racket['stateless] servlet module:
@racketmod[
 web-server
 (require web-server/http)
 (provide interface-version stuffer start)
 (define interface-version 'stateless)
 (define stuffer
   (stuffer-chain
    serialize-stuffer
    (md5-stuffer (build-path (find-system-path 'home-dir) ".urls"))))
 (define (start req)
   (response/xexpr
    `(html (body (h2 "Look ma, no state!")))))
]

The @racketmodname[web-server/base] language exports all of the functions
and syntax from @racketmodname[racket/base] and nothing else.

The @racketmodname[web-server] language exports all of the functions
and syntax from the following libraries: @racketmodname[racket],
@racketmodname[net/url], @racketmodname[web-server/http],
@racketmodname[web-server/http/bindings],
@racketmodname[web-server/lang/abort-resume],
@racketmodname[web-server/lang/web],
@racketmodname[web-server/lang/native],
@racketmodname[web-server/lang/web-param],
@racketmodname[web-server/lang/web-cells],
@racketmodname[web-server/lang/file-box],
@racketmodname[web-server/lang/soft],
@racketmodname[web-server/dispatch], and
@racketmodname[web-server/stuffers].  Some of these are documented in
the subsections that follow.

@include-section["stateless-usage.scrbl"]
@include-section["serial.scrbl"]
@include-section["native.scrbl"]
@include-section["lang.scrbl"]
@include-section["lang-web-cells.scrbl"]
@include-section["file-box.scrbl"]
@include-section["web-param.scrbl"]
@include-section["soft.scrbl"]
@include-section["stuffers.scrbl"]
