c/quickwebserver.c
/**
 * JS-middle-function for passing data to the response. 
 * Finds request with needed ID and sends the data 
 * to the next method
 * 
 */
JS-middle-function for passing data to the response.
Finds request with needed ID and sends the data
to the next method
JS - middle - function for passing data to the response . Finds request with needed ID and sends the data to the next method
static JSValue serverRespond(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) {
	int requestId, requestIndex;
	JS_ToInt32(ctx, &requestId, argv[0]);
	JSRequest *request = getRequestById(requestId, serverRequests, &requestIndex);
	if (!request) {
		JS_ThrowInternalError(ctx, "[QuickWebServer] Request not found");
	}
	struct http_request_s* serverRequest;	
	serverRequest = request->request;
	response(serverRequest, argv[1], ctx);
	ARRAY_REMOVE(serverRequests, requestIndex, 1);
	return JS_NewInt32(ctx, 0);
}
static JSValue serverRespond ( JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) { int requestId , requestIndex ; JS_ToInt32 ( ctx , & requestId , argv [ 0 ] ) ; JSRequest * request = getRequestById ( requestId , serverRequests , & requestIndex ) ; if ( ! request ) { JS_ThrowInternalError ( ctx , " " ) ; } struct http_request_s * serverRequest ; serverRequest = request -> request ; response ( serverRequest , argv [ 1 ] , ctx ) ; ARRAY_REMOVE ( serverRequests , requestIndex , 1 ) ; return JS_NewInt32 ( ctx , 0 ) ; }
JS-middle-function for passing data to the response.
JS - middle - function for passing data to the response .