1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162openFmlib_jstypeerror=[`Statusofint|`No_json|`Decode]moduleBody=structtypecontents=Stringofstring|FileofFile.ttypet={contents:contents;media_type:stringoption;}letempty:t={contents=String"";media_type=None}letstring(media_type:string)(s:string):t={contents=Strings;media_type=Somemedia_type}letjson(v:Value.t):t=(* it's ok to call Option.get here because v is constructed with one of
the functions from Fmlib_browser.Value and thus is guaranteed to be
serializable and its serialization is a string. *)letjson=v|>Value.stringify|>Decoder.string|>Option.getin{contents=Stringjson;media_type=Some"application/json"}letfile(file:File.t):t={contents=Filefile;media_type=File.media_typefile}endmoduleExpect=structtype'at=Http_request.t->('a,error)resultletstring:stringt=funreq->Ok(Http_request.response_text_stringreq)letjson(decode:'aDecoder.t):'at=funreq->matchValue.parse(Http_request.response_text_valuereq)with|None->Error`No_json|Somev->matchdecodevwith|None->Error`Decode|Somea->Okaletmap(f:('a->'b))(expect:'at):'bt=funreq->Result.mapf(expectreq)end