Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HBRequest.collateBody #147

Merged
merged 2 commits into from
Nov 10, 2022
Merged

Add HBRequest.collateBody #147

merged 2 commits into from
Nov 10, 2022

Conversation

adam-fowler
Copy link
Member

Used to collate request body before it reaches the request handler eg in middleware

struct MyMiddleware: HBMiddleware {
    func apply(to request: HBRequest, next: HBResponder) -> EventLoopFuture<HBResponse> {
        return request.collateBody().flatMap { request in
            request.logger.info("Buffer size: \(request.body.buffer!.readableBytes)")
            // note must pass on new request to next responder otherwise the body will be lost
            return next.respond(to: request)
        }
    }
}

Used to collate request body before it reaches the request handler
@codecov
Copy link

codecov bot commented Nov 8, 2022

Codecov Report

Base: 78.97% // Head: 79.01% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (07cad65) compared to base (954e808).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 07cad65 differs from pull request most recent head adb9198. Consider uploading reports for the commit adb9198 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #147      +/-   ##
==========================================
+ Coverage   78.97%   79.01%   +0.03%     
==========================================
  Files          74       74              
  Lines        3187     3192       +5     
==========================================
+ Hits         2517     2522       +5     
  Misses        670      670              
Impacted Files Coverage Δ
Sources/Hummingbird/Server/Request.swift 93.54% <100.00%> (+0.56%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@adam-fowler adam-fowler merged commit c766aa5 into main Nov 10, 2022
@adam-fowler adam-fowler deleted the feature/collate-body branch November 10, 2022 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant