factor/basis/http/server/server-docs.factor

140 lines
5.8 KiB
Factor
Raw Normal View History

USING: help.markup help.syntax io.streams.string quotations strings urls
http vocabs.refresh math io.servers assocs ;
2008-09-27 12:37:46 -04:00
IN: http.server
HELP: trivial-responder
{ $description "The class of trivial responders, which output the same response for every request. New instances are created by calling " { $link <trivial-responder> } "." } ;
HELP: <trivial-responder>
{ $values { "response" response } { "trivial-responder" trivial-responder } }
2008-09-27 12:37:46 -04:00
{ $description "Creates a new trivial responder which outputs the same response for every request." } ;
HELP: benchmark?
{ $var-description "If set to a true value, the HTTP server will log the time taken to process each request." } ;
HELP: call-responder
{ $values
{ "path" "a sequence of strings" } { "responder" "a responder" }
{ "response" response } }
{ $description "Calls a responder." } ;
HELP: call-responder*
{ $values
{ "path" "a sequence of strings" } { "responder" "a responder" }
{ "response" response } }
{ $contract "Processes an HTTP request and returns a response." }
{ $notes "When this word is called, various dynamic variables are set; see " { $link "http.server.requests" } "." } ;
HELP: development?
{ $var-description "If set to a true value, the HTTP server will call " { $link refresh-all } " on each request, and error pages will contain stack traces." } ;
HELP: main-responder
{ $var-description "The responder which will handle HTTP requests." } ;
HELP: post-request?
{ $values { "?" "a boolean" } }
{ $description "Outputs if the current request is a POST request.s" } ;
HELP: responder-nesting
{ $description "A sequence of " { $snippet "{ path responder }" } " pairs." } ;
HELP: http-server
{ $class-description "The class of HTTP servers. New instances are created by calling " { $link <http-server> } "." } ;
HELP: <http-server>
{ $values { "server" http-server } }
{ $description "Creates a new HTTP server with default parameters." } ;
HELP: httpd
{ $values { "port" integer } { "http-server" http-server } }
2008-09-27 12:37:46 -04:00
{ $description "Starts an HTTP server on the specified port number." }
{ $notes "For more flexibility, use " { $link <http-server> } " and fill in the tuple slots before calling " { $link start-server } "." } ;
HELP: http-insomniac
{ $description "Starts a thread which rotates the logs and e-mails a summary of HTTP requests every 24 hours. See " { $link "logging.insomniac" } "." } ;
HELP: request-params
{ $values { "request" request } { "assoc" assoc } }
{ $description "Outputs the query parameters (if the current request is a GET or HEAD request) or the POST parameters (if the current request is a POST request)." } ;
HELP: param
{ $values
{ "name" string }
{ "value" string }
}
{ $description "Outputs the value of a query parameter (if the current request is a GET or HEAD request) or a POST parameter (if the current request is a POST request)." }
{ $notes "Instead of using this word, it is better to use " { $vocab-link "furnace.actions" } " and the associated validation machinery, which allows you to access values using " { $link "html.forms.values" } " words." } ;
HELP: params
{ $var-description "A variable holding an assoc of query parameters (if the current request is a GET or HEAD request) or POST parameters (if the current request is a POST request)." }
{ $notes "Instead of using this word, it is better to use " { $vocab-link "furnace.actions" } " and the associated validation machinery, which allows you to access values using " { $link "html.forms.values" } " words." } ;
2008-09-27 12:37:46 -04:00
ARTICLE: "http.server.requests" "HTTP request variables"
2010-06-28 17:31:45 -04:00
"The following variables are set by the HTTP server at the beginning of a request. Responder implementations may access these variables."
{ $subsections
request
url
responder-nesting
params
}
"Utility words:"
{ $subsections
2010-06-28 17:42:48 -04:00
post-request?
param
set-param
request-params
}
2010-06-28 17:42:48 -04:00
"Additional variables may be set by vocabularies such as " { $vocab-link "html.forms" } " and " { $vocab-link "furnace.sessions" } "." ;
2008-09-27 12:37:46 -04:00
ARTICLE: "http.server.responders" "HTTP server responders"
2010-06-28 17:31:45 -04:00
"Responders process requests and output " { $link "http.responses" } ". To implement a responder, define a new class and implement a method on the following generic word:"
{ $subsections call-responder* }
2008-09-27 12:37:46 -04:00
"The HTTP server dispatches requests to a main responder:"
{ $subsections main-responder }
2010-06-28 17:31:45 -04:00
"The main responder may in turn dispatch it a subordinate dispatcher, and so on. To call a subordinate responder, use the following word:"
{ $subsections call-responder }
2008-09-27 12:37:46 -04:00
"A simple implementation of a responder which always outputs the same response:"
{ $subsections
trivial-responder
<trivial-responder>
}
2010-06-28 17:31:45 -04:00
"Writing new responders by hand is rarely necessary, because in most cases it is easier to use " { $vocab-link "furnace.actions" } " instead."
{ $vocab-subsection "Furnace actions" "furnace.actions" } ;
2008-09-27 12:37:46 -04:00
ARTICLE: "http.server.variables" "HTTP server variables"
"The following global variables control the behavior of the HTTP server. Both are off by default."
{ $subsections
development?
benchmark?
} ;
2008-09-27 12:37:46 -04:00
ARTICLE: "http.server" "HTTP server"
"The " { $vocab-link "http.server" } " vocabulary implements an HTTP and HTTPS server on top of " { $vocab-link "io.servers" } "."
{ $subsections
"http.server.responders"
"http.server.requests"
}
2008-09-27 12:37:46 -04:00
"Various types of responders are defined in other vocabularies:"
{ $subsections
"http.server.dispatchers"
"http.server.filters"
}
2008-09-27 12:37:46 -04:00
"Useful canned responses:"
{ $subsections
"http.server.responses"
"http.server.redirection"
}
2008-09-27 12:37:46 -04:00
"Configuration:"
{ $subsections
"http.server.variables"
"http.server.remapping"
}
2008-09-27 12:37:46 -04:00
"Features:"
{ $subsections
"http.server.static"
"http.server.cgi"
}
2008-09-27 12:37:46 -04:00
"The " { $vocab-link "furnace" } " framework implements high-level abstractions which make developing web applications much easier than writing responders by hand." ;
ABOUT: "http.server"