Skip to content

Conversation

@johanandren
Copy link
Contributor

@johanandren johanandren commented Jan 16, 2024

Based on https://github.com/lomigmegard/akka-http-cors but simplified here and there with less API surface, also a few optimisations.

with WebSocketDirectives
with FramedEntityStreamingDirectives
with AttributeDirectives
with CorsDirectives
Copy link
Contributor Author

@johanandren johanandren Jan 16, 2024

Choose a reason for hiding this comment

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

This can cause problems for users having the original cors directive imported and also using Directives to import all built in, because method names will collide.

Maybe that is fine though and the recommendation is to move over to the built in cors support?

@johanandren johanandren marked this pull request as ready for review January 17, 2024 11:25
@johanandren johanandren changed the title WIP: first step towards built in CORS-support in akka-http feat: CORS-support Jan 17, 2024
@johanandren
Copy link
Contributor Author

The overhead for regular CORS requests is a bit more expensive than I would have hoped, up to 10%, but couldn't find a way to optimise it further (it needs to copy/filter headers).

Copy link
Contributor Author

@johanandren johanandren Jan 17, 2024

Choose a reason for hiding this comment

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

This would be better just benching the directive/route rather than an end to end server test over TCP, but might be good enough for now.

Copy link
Contributor

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM, maybe we should start a migration-guide page informing about this addition and how to migrate?


# Configuration for the cors directive, does not apply unless the directive is used
#cors
cors {
Copy link
Contributor

Choose a reason for hiding this comment

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

both package names and config are different from akka-http-cors, so there shouldn't be any problems for users that still have akka-http-cors in classpath, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is what I mentioned in #4343 (comment)

We have an import-all directives-object/baseclass, now including cors(), if the original library is also in scope that will clash and not compile, not entirely sure what happens for the scenario of bumping without recompiling (but the original library does not support newer Akka versions so maybe that is a non issue?)

@johanandren
Copy link
Contributor Author

I agree, a migration page of some sort would be good to add. Will do.

Copy link
Contributor

@ennru ennru left a comment

Choose a reason for hiding this comment

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

LGTM.

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.

4 participants