char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
c013baf
main
1use std:: convert:: Infallible ; 2 3use avril_core:: serde_v8:: JsBuffer ; 4use avril_core::{ Extension , Op }; 5 6pub fn init () ->Extension { 7Extension { 8name : "ext:form_data" , 9dependencies : & [ "ext:blob" , "ext:encoding" , "ext:web" ], 10ops : vec! [ 11Op :: new ( "op_form_data_boundary" , |(): () |{ 12let mut bytes =[ 0 ; 16 ]; 13 getrandom:: fill ( & mut bytes) ?; 14let mut boundary =String :: from ( "----avril" ); 15for bytein bytes{ 16use std:: fmt:: Write ; 17write! ( boundary, "{byte:02x}" ). unwrap (); 18} 19Ok ::< _ , getrandom:: Error >( boundary) 20}), 21Op :: new ( "op_form_data_urlencoded" , |bytes : JsBuffer |{ 22let pairs = url:: form_urlencoded:: parse ( & bytes) 23. map ( |( name, value) |( name. into_owned (), value. into_owned ())) 24. collect ::< Vec < _ >>(); 25Ok ::< _ , Infallible >( pairs) 26}), 27], 28modules : & [ 29( 30"ext:form_data/main.js" , 31include_str! ( concat! ( env! ( "OUT_DIR" ), "/main.js" )), 32), 33( 34"ext:form_data/form_data.js" , 35include_str! ( concat! ( env! ( "OUT_DIR" ), "/form_data.js" )), 36), 37( 38"ext:form_data/multipart.js" , 39include_str! ( concat! ( env! ( "OUT_DIR" ), "/multipart.js" )), 40), 41], 42entry_point : Some ( "ext:form_data/main.js" ), 43} 44}