Skip to content

Commit 574193c

Browse files
author
Bryce Nichols
committed
change to api to provide stream names when getting full list
1 parent 62078a6 commit 574193c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

nginx.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,16 @@ module Upstream = struct
122122
let list ng =
123123
do_api8_get_req ng [ "http"; "upstreams" ] (fun resp -> List.map snd (Nginx_j.upstream_collection_of_string resp))
124124

125+
(** Fetch a list of all upstreams configured (with names) *)
126+
let list_with_names ng =
127+
let to_upstream (nm, us) = (upstream_id nm, us) in
128+
do_api8_get_req ng [ "http"; "upstreams" ] (fun resp -> List.map to_upstream (Nginx_j.upstream_collection_of_string resp))
129+
125130
(* val get : nginx -> upstream_id -> t r *)
126131

127132
(** Fetch state and configuration of the given upstream *)
128133
let get ng upstr_id =
129-
do_api8_get_req ng [ "http"; "upstreams"; upstr_id ] (fun (str : string) -> Nginx_j.upstream_of_string str)
134+
do_api8_get_req ng [ "http"; "upstreams"; upstr_id ] Nginx_j.upstream_of_string
130135

131136
(* val reset : nginx -> upstream_id -> unit r *)
132137

nginx.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ module Upstream : sig
4444

4545
val upstream_id : string -> upstream_id
4646

47+
(** Fetch a list of all upstreams configured (with names) *)
48+
val list_with_names : nginx -> (upstream_id * t) list r
49+
4750
(** Fetch a list of all upstreams configured *)
4851
val list : nginx -> t list r
4952

0 commit comments

Comments
 (0)