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

Akka http cors #122

Open
wants to merge 4 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h1 id="server-side">I want to add CORS support to my server</h1>

<p>If you'd like to learn more about implementing CORS for a specific platform, follow one of the links below:</p>
<ul>
<li><a href="server_akkahttp.html">Akka HTTP</a></li>
<li><a href="server_apache.html">Apache</a></li>
<li><a href="server_appengine.html">App Engine</a></li>
<li><a href="server_aspnet.html">ASP.NET</a></li>
Expand Down
31 changes: 31 additions & 0 deletions server_akkahttp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
layout: default
title: enable cross-origin resource sharing
---

<div class="container">
<section>
<h1>CORS on Akka HTTP</h1>

<p>
To add CORS to <a href="http://doc.akka.io/docs/akka-http/current/">Akka HTTP</a> application, use the <a href="https://github.com/lomigmegard/akka-http-cors">akka-http-cors</a> library.
</p>
<p>
The simplest way to enable CORS in your application is to use the cors directive. Settings are passed as a parameter to the directive, with defaults provided for convenience.
</p>
<pre class="code">import ch.megard.akka.http.cors.scaladsl.CorsDirectives._

val route: Route = cors() {
complete(...)
}</pre>

<p>
The default settings can be used as a baseline to customize the CORS directive behaviour.
</p>
<pre class="code">val settings = CorsSettings.defaultSettings.copy(allowGenericHttpRequests = false)
val strictRoute: Route = cors(settings) {
complete(...)
}</pre>
</section>

</div>