mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-08 04:05:35 -05:00
25 lines
864 B
OCaml
25 lines
864 B
OCaml
(** Websockets for Tiny_httpd.
|
|
|
|
This sub-library ([tiny_httpd.ws]) exports a small implementation
|
|
for a websocket server. It has no additional dependencies.
|
|
*)
|
|
|
|
open Tiny_httpd_server
|
|
module IO = Tiny_httpd_io
|
|
|
|
type handler = Unix.sockaddr -> IO.Input.t -> IO.Output.t -> unit
|
|
(** Websocket handler *)
|
|
|
|
val upgrade : IO.Input.t -> IO.Output.t -> IO.Input.t * IO.Output.t
|
|
(** Upgrade a byte stream to the websocket framing protocol. *)
|
|
|
|
val add_route_handler :
|
|
?accept:(unit Request.t -> (unit, int * string) result) ->
|
|
?accept_ws_protocol:(string -> bool) ->
|
|
Tiny_httpd_server.t ->
|
|
(upgrade_handler, upgrade_handler) Route.t ->
|
|
handler ->
|
|
unit
|
|
(** Add a route handler for a websocket endpoint.
|
|
@param accept_ws_protocol decides whether this endpoint accepts the websocket protocol
|
|
sent by the client. Default accepts everything. *)
|