teragrep / cfe_31

0 stars 0 forks source link

Refactor HttpClient usage #10

Closed MoonBow-1 closed 8 months ago

MoonBow-1 commented 8 months ago
  1. Logging

Currently sending requests only returns an HttpResponse object, which is then individually logged by the sender.

The plan is to log the response at the client level, and not use the same duplicate code after returning the HttpResponse object.

Logging is simple and universal with this:

if (response == null) {
    Typewriter.technical_error("Response was null");
} else if (response.statusCode() == 201 || response.statusCode() == 200) {
    Typewriter.response(response.body());
} else {
    Typewriter.errorResponse(response.body());
}
  1. Generating requests and sending them

Currently: Client is first initialized, then a request is generated from the client object and stored in a var, then client is called with that var.

Plan is to make that var into the client object, and just call void methods to send it, and add store the response inside the client object.

MoonBow-1 commented 8 months ago

These changes also will improve the CaptureDefWithSink objects by removing a method from both. Elsewhere these changes remove 6-9 lines of code.

MoonBow-1 commented 8 months ago

All changes done in commit 9f641203, moving ticket to QA

MoonBow-1 commented 8 months ago

Merged