diff --git a/dev/tiny_httpd/Tiny_httpd/index.html b/dev/tiny_httpd/Tiny_httpd/index.html index ac95d6cd..0b3a4921 100644 --- a/dev/tiny_httpd/Tiny_httpd/index.html +++ b/dev/tiny_httpd/Tiny_httpd/index.html @@ -49,7 +49,7 @@ echo: Accept: */* Content-Length: 10 Content-Type: application/x-www-form-urlencoded; - path="/echo"; body="howdy y'all"}
These buffers are used to avoid allocating too many byte arrays when processing streams and parsing requests.
module Buf = Tiny_httpd_bufmodule Byte_stream = Tiny_httpd_streamtype buf = Tiny_httpd_buf.ttype byte_stream = Tiny_httpd_stream.tmodule Meth = Tiny_httpd_server.MethHeaders are metadata associated with a request or response.
module Headers = Tiny_httpd_server.HeadersRequests are sent by a client, e.g. a web browser or cURL. From the point of view of the server, they're inputs.
module Request = Tiny_httpd_server.Requestmodule Response_code = Tiny_httpd_server.Response_codeResponses are what a http server, such as Tiny_httpd, send back to the client to answer a Request.t
module Response = Tiny_httpd_server.ResponseBasic type-safe routing of handlers based on URL paths. This is optional, it is possible to only define the root handler with something like Routes.
module Route = Tiny_httpd_server.RouteA middleware can be inserted in a handler to modify or observe its behavior.
module Middleware = Tiny_httpd_server.Middlewaretype t = Tiny_httpd_server.tA HTTP server. See create for more details.
val create :
+ path="/echo"; body="howdy y'all"}These buffers are used to avoid allocating too many byte arrays when processing streams and parsing requests.
module Buf = Tiny_httpd_bufmodule Byte_stream = Tiny_httpd_streammodule IO = Tiny_httpd_iotype buf = Tiny_httpd_buf.ttype byte_stream = Tiny_httpd_stream.tmodule Meth = Tiny_httpd_server.MethHeaders are metadata associated with a request or response.
module Headers = Tiny_httpd_server.HeadersRequests are sent by a client, e.g. a web browser or cURL. From the point of view of the server, they're inputs.
module Request = Tiny_httpd_server.Requestmodule Response_code = Tiny_httpd_server.Response_codeResponses are what a http server, such as Tiny_httpd, send back to the client to answer a Request.t
module Response = Tiny_httpd_server.ResponseBasic type-safe routing of handlers based on URL paths. This is optional, it is possible to only define the root handler with something like Routes.
module Route = Tiny_httpd_server.RouteA middleware can be inserted in a handler to modify or observe its behavior.
module Middleware = Tiny_httpd_server.Middlewaretype t = Tiny_httpd_server.tA HTTP server. See create for more details.
val create :
?masksigpipe:bool ->
?max_connections:int ->
?timeout:float ->
@@ -61,7 +61,12 @@ echo:
?sock:Unix.file_descr ->
?middlewares:([ `Encoding | `Stage of int ] * Middleware.t) list ->
unit ->
- tCreate a new webserver.
The server will not do anything until run is called on it. Before starting the server, one can use add_path_handler and set_top_handler to specify how to handle incoming requests.
val addr : t -> stringAddress on which the server listens.
val is_ipv6 : t -> boolis_ipv6 server returns true iff the address of the server is an IPv6 address.
val port : t -> intPort on which the server listens. Note that this might be different than the port initially given if the port was 0 (meaning that the OS picks a port for us).
val active_connections : t -> intNumber of currently active connections.
val add_decode_request_cb :
+ tCreate a new webserver using UNIX abstractions.
The server will not do anything until run is called on it. Before starting the server, one can use add_path_handler and set_top_handler to specify how to handle incoming requests.
module type IO_BACKEND = Tiny_httpd_server.IO_BACKENDA backend that provides IO operations, network operations, etc.
val create_from :
+ ?buf_size:int ->
+ ?middlewares:([ `Encoding | `Stage of int ] * Middleware.t) list ->
+ backend:(module IO_BACKEND) ->
+ unit ->
+ tCreate a new webserver using provided backend.
The server will not do anything until run is called on it. Before starting the server, one can use add_path_handler and set_top_handler to specify how to handle incoming requests.
val addr : t -> stringAddress on which the server listens.
val is_ipv6 : t -> boolis_ipv6 server returns true iff the address of the server is an IPv6 address.
val port : t -> intPort on which the server listens. Note that this might be different than the port initially given if the port was 0 (meaning that the OS picks a port for us).
val active_connections : t -> intNumber of currently active connections.
val add_decode_request_cb :
t ->
(unit Request.t -> (unit Request.t * (byte_stream -> byte_stream)) option) ->
unitAdd a callback for every request. The callback can provide a stream transformer and a new request (with modified headers, typically). A possible use is to handle decompression by looking for a Transfer-Encoding header and returning a stream transformer that decompresses on the fly.
val add_encode_response_cb :
@@ -90,4 +95,4 @@ echo:
t ->
('a, string Request.t -> server_sent_generator -> unit) Route.t ->
'a ->
- unitAdd a handler on an endpoint, that serves server-sent events.
The callback is given a generator that can be used to send events as it pleases. The connection is always closed by the client, and the accepted method is always GET. This will set the header "content-type" to "text/event-stream" automatically and reply with a 200 immediately. See server_sent_generator for more details.
This handler stays on the original thread (it is synchronous).
val stop : t -> unitAsk the server to stop. This might not have an immediate effect as run might currently be waiting on IO.
val run : ?after_init:(unit -> unit) -> t -> (unit, exn) Stdlib.resultRun the main loop of the server, listening on a socket described at the server's creation time, using new_thread to start a thread for each new client.
This returns Ok () if the server exits gracefully, or Error e if it exits with an error.
module Util = Tiny_httpd_utilmodule Dir = Tiny_httpd_dirmodule Html = Tiny_httpd_htmlAlias to Tiny_httpd_html