···11-type query =
22- { feed: string
33- ; limit: int option [@default None]
44- ; cursor: string option [@default None] }
55-[@@deriving yojson {strict= false}]
11+open Lexicons.App.Bsky.Feed.GetFeed.Main
6273let handler =
84 Xrpc.handler ~auth:Authorization (fun ctx ->
99- let input = Xrpc.parse_query ctx.req query_of_yojson in
55+ let input = Xrpc.parse_query ctx.req params_of_yojson in
106 match Util.Syntax.parse_at_uri input.feed with
117 | None ->
128 Errors.invalid_request ("invalid feed URI " ^ input.feed)
+21-4
pegasus/lib/xrpc.ml
···167167 (of_yojson : Yojson.Safe.t -> ('a, string) result) : 'a =
168168 try
169169 let queries = Dream.all_queries req in
170170+ (* group repeated keys into JSON arrays, single keys stay as strings *)
171171+ let tbl = Hashtbl.create 16 in
172172+ let order = ref [] in
173173+ List.iter
174174+ (fun (k, v) ->
175175+ if not (Hashtbl.mem tbl k) then order := k :: !order ;
176176+ let prev = try Hashtbl.find tbl k with Not_found -> [] in
177177+ Hashtbl.replace tbl k (prev @ [v]) )
178178+ queries ;
170179 let query_json =
171180 `Assoc
172172- (List.map
173173- (fun (k, v) ->
174174- (k, try Yojson.Safe.from_string v with _ -> `String v) )
175175- queries )
181181+ (List.rev_map
182182+ (fun k ->
183183+ let vs = Hashtbl.find tbl k in
184184+ let v =
185185+ match vs with
186186+ | [v] ->
187187+ `String v
188188+ | vs ->
189189+ `List (List.map (fun v -> `String v) vs)
190190+ in
191191+ (k, v) )
192192+ !order )
176193 in
177194 match query_json |> of_yojson with
178195 | Error e ->