Skip to content

Commit

Permalink
add optional middlewares to tiny_httpd_ws
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Apr 15, 2024
1 parent 241d9ae commit 284d1f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ws/tiny_httpd_ws.ml
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ struct
()
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 =
let module M = Make_upgrade_handler (struct
let handler = f
let accept_ws_protocol = accept_ws_protocol
end) 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
let apply_masking = Reader.apply_masking
Expand Down
1 change: 1 addition & 0 deletions src/ws/tiny_httpd_ws.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exception Close_connection
val add_route_handler :
?accept:(unit Request.t -> (unit, int * string) result) ->
?accept_ws_protocol:(string -> bool) ->
?middlewares:Server.Head_middleware.t list ->
Server.t ->
(Server.upgrade_handler, Server.upgrade_handler) Route.t ->
handler ->
Expand Down

0 comments on commit 284d1f7

Please sign in to comment.