mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
add optional middlewares to tiny_httpd_ws
This commit is contained in:
parent
241d9aeaf1
commit
284d1f7400
2 changed files with 3 additions and 2 deletions
|
|
@ -468,14 +468,14 @@ struct
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
|
||||||
let add_route_handler ?accept ?(accept_ws_protocol = fun _ -> true)
|
let add_route_handler ?accept ?(accept_ws_protocol = fun _ -> true) ?middlewares
|
||||||
(server : Server.t) route (f : handler) : unit =
|
(server : Server.t) route (f : handler) : unit =
|
||||||
let module M = Make_upgrade_handler (struct
|
let module M = Make_upgrade_handler (struct
|
||||||
let handler = f
|
let handler = f
|
||||||
let accept_ws_protocol = accept_ws_protocol
|
let accept_ws_protocol = accept_ws_protocol
|
||||||
end) in
|
end) in
|
||||||
let up : Server.upgrade_handler = (module M) in
|
let up : Server.upgrade_handler = (module M) in
|
||||||
Server.add_upgrade_handler ?accept server route up
|
Server.add_upgrade_handler ?accept ?middlewares server route up
|
||||||
|
|
||||||
module Private_ = struct
|
module Private_ = struct
|
||||||
let apply_masking = Reader.apply_masking
|
let apply_masking = Reader.apply_masking
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ exception Close_connection
|
||||||
val add_route_handler :
|
val add_route_handler :
|
||||||
?accept:(unit Request.t -> (unit, int * string) result) ->
|
?accept:(unit Request.t -> (unit, int * string) result) ->
|
||||||
?accept_ws_protocol:(string -> bool) ->
|
?accept_ws_protocol:(string -> bool) ->
|
||||||
|
?middlewares:Server.Head_middleware.t list ->
|
||||||
Server.t ->
|
Server.t ->
|
||||||
(Server.upgrade_handler, Server.upgrade_handler) Route.t ->
|
(Server.upgrade_handler, Server.upgrade_handler) Route.t ->
|
||||||
handler ->
|
handler ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue