Skip to content

Commit

Permalink
Upgrade dependencies and release 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Schaefermeyer committed Dec 6, 2017
1 parent 486c000 commit 44fd663
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v.1.5.0

* Enhancements
* Allow configuration of origin via function (thanks @mauricioszabo).

## v.1.4.0

* Enhancements
Expand Down
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,44 @@ On `GET`, `POST`, ... requests:
* Access-Control-Expose-Headers
* Access-Control-Allow-Credentials

You can configure allowed origins as follows:
You can configure allowed origins using one of the following methods:

### Using a list

```elixir
plug CORSPlug, origin: ["http://example1.com", "http://example2.com"]
```

Alternatively, you can use a regex:
### Using a regex

```elixir
plug CORSPlug, origin: ~r/https?.*example\d?\.com$/
```

And also you can put configuration into config.exs:
### Using the config.exs file

```elixir
config :cors_plug,
origin: ["foo.bar"],
max_age: 86400,
methods: ["GET", "POST"]
```
Please note that options passed to the plug overrides app config but app config overrides default options.

Please find the list of current defaults in [cors_plug.ex](lib/cors_plug.ex#L5:L15).
### Using a `function/0` that returns the allowed origin as a string

```elixir
plug CORSPlug, origin: fn -> "example.com" end
```

Please note that options passed to the plug overrides app config but app config
overrides default options.

Please find the list of current defaults in
[cors_plug.ex](lib/cors_plug.ex#L5:L15).

## License

Copyright 2014 Michael Schaefermeyer
Copyright 2017 Michael Schaefermeyer

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ use Mix.Config
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"

config :plug, :validate_header_keys_during_test, true
18 changes: 3 additions & 15 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule CorsPlug.Mixfile do
def project do
[
app: :cors_plug,
version: "1.4.0",
elixir: ">= 1.0.0",
version: "1.5.0",
elixir: "~> 1.3",
deps: deps(),
package: package(),
description: description(),
Expand All @@ -15,25 +15,13 @@ defmodule CorsPlug.Mixfile do
]
end

# Configuration for the OTP application
#
# Type `mix help compile.app` for more information
def application do
[applications: [:logger]]
end

# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
#
# Type `mix help deps` for more examples and options
defp deps do
[
{:plug, "> 0.14.0"},
{:plug, "~> 1.4"},

{:ex_doc, "~> 0.11", only: :dev},
{:earmark, "~> 1.2", only: :dev},
Expand Down
8 changes: 4 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:make, :rebar], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.16.1", "b4b8a23602b4ce0e9a5a960a81260d1f7b29635b9652c67e95b0c2f7ccee5e81", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
"mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], []},
"plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]},
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm"},
"plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
"ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []}}

0 comments on commit 44fd663

Please sign in to comment.