handshake(server): Make 'create_response_with_body' function more generic

This makes using it possible when the request and response body types differ.

Signed-off-by: bartel <bartel.sielski@gmail.com>
This commit is contained in:
Bartel Sielski 2024-04-23 16:45:36 +02:00 committed by GitHub
parent 0fa41973b4
commit 60c50cdea2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -86,10 +86,10 @@ pub fn create_response(request: &Request) -> Result<Response> {
}
/// Create a response for the request with a custom body.
pub fn create_response_with_body<T>(
request: &HttpRequest<T>,
generate_body: impl FnOnce() -> T,
) -> Result<HttpResponse<T>> {
pub fn create_response_with_body<T1, T2>(
request: &HttpRequest<T1>,
generate_body: impl FnOnce() -> T2,
) -> Result<HttpResponse<T2>> {
Ok(create_parts(request)?.body(generate_body())?)
}