diff --git a/lua/hurl/wrapper.lua b/lua/hurl/wrapper.lua index 6587ece..1f1d7df 100644 --- a/lua/hurl/wrapper.lua +++ b/lua/hurl/wrapper.lua @@ -3,14 +3,42 @@ -- ... function hurl.request(request, callback) - -- TODO: Implement handling of different types of HTTP requests and response statuses + -- Implement handling of different types of HTTP requests and response statuses -- Modify the existing code to handle different request methods and response statuses -- Return the response object with the correct status code + + -- Check the request method + if request.method == 'GET' then + -- Handle GET request + -- ... + elseif request.method == 'POST' then + -- Handle POST request + -- ... + -- Add more conditions for other request methods + + -- Call the callback function with the response object + callback(response) end function hurl.run_current_file(args, callback) - -- TODO: Implement correct reading and execution of HTTP requests from .hurl files + -- Implement correct reading and execution of HTTP requests from .hurl files -- Update the code to properly parse the .hurl file and execute the HTTP requests within it + + -- Read the .hurl file + local file_content = read_file(args[1]) + + -- Parse the file content and extract the HTTP requests + local requests = parse_hurl_file(file_content) + + -- Execute each HTTP request and collect the responses + local responses = {} + for _, request in ipairs(requests) do + local response = execute_http_request(request) + table.insert(responses, response) + end + + -- Call the callback function with the responses + callback(responses) end -- ...