@prostory/mountain
Version:
Yet another HTTP/2 server and client.
3 lines (2 loc) • 845 B
JavaScript
import{constants as r}from"http2";import{createUrl as e}from"../utils/url.js";import{json as t}from"./body/json.js";import{text as o}from"./body/text.js";import{formData as s}from"./body/form_data.js";import{urlencoded as a}from"./body/urlencoded.js";var d;!function(r){r.TEXT="text",r.JSON="json",r.FORM_DATA="form-data",r.URLENCODED="urlencoded"}(d||(d={}));const m=r=>({header:(e,t=(r=>r))=>t(r.headers[e]),body:(e,d)=>{switch(e){case"text":return o(r.stream);case"json":return t(r.stream,r.headers);case"form-data":return s(r.stream,r.headers,d);case"urlencoded":return a(r.stream,r.headers);default:return Promise.resolve()}}}),n=t=>({...m(t),url:e(t.headers),method:t.headers[r.HTTP2_HEADER_METHOD],parameters:t.parameters}),u=r=>({...m(r)});export{d as BodyType,n as accessRequest,u as accessResponse};
//# sourceMappingURL=access.js.map