]> gitweb.factorcode.org Git - factor.git/blob - basis/http/server/responses/responses-docs.factor
d4bbd4c986289a86f8dcc2e3b1cd2747958d6a5d
[factor.git] / basis / http / server / responses / responses-docs.factor
1 USING: help.markup help.syntax io.streams.string strings
2 http math furnace.json ;
3 IN: http.server.responses
4
5 HELP: <content>
6 { $values { "body" "a response body" } { "content-type" string } { "response" response } }
7 { $description "Creates a successful HTTP response which sends a response body with the specified content type to the client." } ;
8
9 HELP: <text-content>
10 { $values { "body" "a response body" } { "response" response } }
11 { $description "Creates a response with content type " { $snippet "text/plain" } "." } ;
12
13 HELP: <html-content>
14 { $values { "body" "a response body" } { "response" response } }
15 { $description "Creates a response with content type " { $snippet "text/html" } "." } ;
16
17 { <content> <text-content> <html-content> } related-words
18
19 HELP: <trivial-response>
20 { $values { "code" integer } { "message" string } { "response" response } }
21 { $description "Creates an HTTP error response." }
22 { $examples
23     { $code
24         "USE: http.server.responses"
25         "415 \"Unsupported Media Type\" <trivial-response>"
26     }
27 } ;
28
29 ARTICLE: "http.server.responses" "Canned HTTP responses"
30 "The " { $vocab-link "http.server.responses" } " vocabulary provides constructors for a few useful " { $link response } " objects." $nl
31 "For successful responses:"
32 { $subsections
33     <content>
34     <text-content>
35     <html-content>
36 }
37 "For errors:"
38 { $subsections
39     <304>
40     <403>
41     <400>
42     <404>
43 }
44 "New error responses like the above can be created for other error codes too:"
45 { $subsections <trivial-response> } ;
46
47 ABOUT: "http.server.responses"