Skip to content

feat(core): add WindowBuilder::on_request, closes #3533#3618

Merged
lucasfernog merged 5 commits intodevfrom
feat/change-response
Mar 6, 2022
Merged

feat(core): add WindowBuilder::on_request, closes #3533#3618
lucasfernog merged 5 commits intodevfrom
feat/change-response

Conversation

@lucasfernog
Copy link
Member

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

@lucasfernog lucasfernog requested a review from a team March 5, 2022 20:11
@lucasfernog lucasfernog requested a review from a team as a code owner March 5, 2022 20:11
/// Ok(())
/// });
/// ```
pub fn on_request<F: Fn(&HttpRequest, &mut HttpResponse) + Send + Sync + 'static>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt about renaming this method to something more specific? This might clash with IPC requests callbacks we implement in the future 🤔
Maybe on_http_request ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I thought about that too, though http might confuse users too..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's true, even though custom protocols are technically still http right?
Alternatively on_network_request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think we'll have to go with http_request as it's more specific

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option that'd be more familiar to electron converts:
on_protocol_request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webview2 calls it WebResourceRequested, I like that one, so I changed to on_web_resource_request.

if let Some(csp) = &asset.csp_header {
builder = builder.header("Content-Security-Policy", csp);
}
match builder.body(asset.bytes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why match here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to do something with an error but it doesn't make sense, gonna revert

@lucasfernog lucasfernog merged commit 3b13fda into dev Mar 6, 2022
@lucasfernog lucasfernog deleted the feat/change-response branch March 6, 2022 13:15
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.

2 participants