changed
CHANGELOG.md
|
@@ -1,3 +1,8 @@
|
1
|
+ # v0.4.3
|
2
|
+
|
3
|
+ * Enhancements
|
4
|
+ * Update to Elixir v0.13.2
|
5
|
+
|
1
6
|
# v0.4.2
|
2
7
|
|
3
8
|
* Enhancements
|
changed
README.md
|
@@ -40,14 +40,14 @@ Access "https://localhost:4000" and we are done!
|
40
40
|
|
41
41
|
## Installation
|
42
42
|
|
43
|
- In practice, you want to use plugs in your existing projects. You can do that in two steps:
|
43
|
+ You can use plug in your projects in two steps:
|
44
44
|
|
45
45
|
1. Add plug and your webserver of choice (currently cowboy) to your `mix.exs` dependencies:
|
46
46
|
|
47
47
|
```elixir
|
48
48
|
def deps do
|
49
|
- [ {:cowboy, github: "extend/cowboy"},
|
50
|
- {:plug, PLUG_VERSION, github: "elixir-lang/plug"} ]
|
49
|
+ [{:cowboy, github: "extend/cowboy"},
|
50
|
+ {:plug, "~> 0.4.2"}]
|
51
51
|
end
|
52
52
|
```
|
53
53
|
|
|
@@ -55,10 +55,12 @@ In practice, you want to use plugs in your existing projects. You can do that in
|
55
55
|
|
56
56
|
```elixir
|
57
57
|
def application do
|
58
|
- [ applications: [:cowboy, :plug] ]
|
58
|
+ [applications: [:cowboy, :plug]]
|
59
59
|
end
|
60
60
|
```
|
61
61
|
|
62
|
+ Note: if you are using Elixir master, please use Plug master (from git) as well.
|
63
|
+
|
62
64
|
## The Plug.Conn
|
63
65
|
|
64
66
|
In the hello world example, we defined our first plug. What is a plug after all?
|
changed
hex_metadata.config
|
@@ -3,23 +3,24 @@
|
3
3
|
{<<"description">>,
|
4
4
|
<<"A specification and conveniences for composable modules in between web applications">>}.
|
5
5
|
{<<"files">>,
|
6
|
- [<<"lib/plug/adapters/cowboy/conn.ex">>,
|
7
|
- <<"lib/plug/adapters/cowboy/handler.ex">>,<<"lib/plug/adapters/cowboy.ex">>,
|
6
|
+ [<<"lib/plug.ex">>,<<"lib/plug/adapters/cowboy.ex">>,
|
7
|
+ <<"lib/plug/adapters/cowboy/conn.ex">>,
|
8
|
+ <<"lib/plug/adapters/cowboy/handler.ex">>,
|
8
9
|
<<"lib/plug/adapters/test/conn.ex">>,<<"lib/plug/builder.ex">>,
|
9
|
- <<"lib/plug/conn/adapter.ex">>,<<"lib/plug/conn/cookies.ex">>,
|
10
|
- <<"lib/plug/conn/query.ex">>,<<"lib/plug/conn/unfetched.ex">>,
|
11
|
- <<"lib/plug/conn/utils.ex">>,<<"lib/plug/conn.ex">>,
|
10
|
+ <<"lib/plug/conn.ex">>,<<"lib/plug/conn/adapter.ex">>,
|
11
|
+ <<"lib/plug/conn/cookies.ex">>,<<"lib/plug/conn/query.ex">>,
|
12
|
+ <<"lib/plug/conn/unfetched.ex">>,<<"lib/plug/conn/utils.ex">>,
|
12
13
|
<<"lib/plug/exceptions.ex">>,<<"lib/plug/head.ex">>,
|
13
14
|
<<"lib/plug/method_override.ex">>,<<"lib/plug/mime.ex">>,
|
14
|
- <<"lib/plug/mime.types">>,<<"lib/plug/parsers/multipart.ex">>,
|
15
|
- <<"lib/plug/parsers/urlencoded.ex">>,<<"lib/plug/parsers.ex">>,
|
16
|
- <<"lib/plug/router/utils.ex">>,<<"lib/plug/router.ex">>,
|
17
|
- <<"lib/plug/session/ets.ex">>,<<"lib/plug/session/store.ex">>,
|
18
|
- <<"lib/plug/session.ex">>,<<"lib/plug/static.ex">>,
|
15
|
+ <<"lib/plug/mime.types">>,<<"lib/plug/parsers.ex">>,
|
16
|
+ <<"lib/plug/parsers/multipart.ex">>,<<"lib/plug/parsers/urlencoded.ex">>,
|
17
|
+ <<"lib/plug/router.ex">>,<<"lib/plug/router/utils.ex">>,
|
18
|
+ <<"lib/plug/session.ex">>,<<"lib/plug/session/ets.ex">>,
|
19
|
+ <<"lib/plug/session/store.ex">>,<<"lib/plug/static.ex">>,
|
19
20
|
<<"lib/plug/supervisor.ex">>,<<"lib/plug/test.ex">>,
|
20
|
- <<"lib/plug/upload.ex">>,<<"lib/plug/wrapper.ex">>,<<"lib/plug.ex">>,
|
21
|
- <<"mix.exs">>,<<"README.md">>,<<"LICENSE">>,<<"CHANGELOG.md">>]}.
|
21
|
+ <<"lib/plug/upload.ex">>,<<"lib/plug/wrapper.ex">>,<<"mix.exs">>,
|
22
|
+ <<"README.md">>,<<"LICENSE">>,<<"CHANGELOG.md">>]}.
|
22
23
|
{<<"licenses">>,[<<"Apache 2">>]}.
|
23
24
|
{<<"links">>,#{<<"Github">> => <<"https://github.com/elixir-lang/plug">>}}.
|
24
25
|
{<<"requirements">>,#{}}.
|
25
|
- {<<"version">>,<<"0.4.2">>}.
|
26
|
+ {<<"version">>,<<"0.4.3">>}.
|
changed
lib/plug.ex
|
@@ -48,7 +48,7 @@ defmodule Plug do
|
48
48
|
@type opts :: tuple | atom | integer | float | [opts]
|
49
49
|
|
50
50
|
use Behaviour
|
51
|
- use Application.Behaviour
|
51
|
+ use Application
|
52
52
|
|
53
53
|
defcallback init(opts) :: opts
|
54
54
|
defcallback call(Plug.Conn.t, opts) :: Plug.Conn.t
|
changed
lib/plug/adapters/cowboy/conn.ex
|
@@ -30,7 +30,7 @@ defmodule Plug.Adapters.Cowboy.Conn do
|
30
30
|
end
|
31
31
|
|
32
32
|
def send_file(req, status, headers, path) do
|
33
|
- File.Stat[type: :regular, size: size] = File.stat!(path)
|
33
|
+ %File.Stat{type: :regular, size: size} = File.stat!(path)
|
34
34
|
body_fun = fn(socket, transport) -> transport.sendfile(socket, path) end
|
35
35
|
|
36
36
|
{:ok, req} = R.reply(status, headers, R.set_resp_body_fun(size, body_fun, req))
|
changed
lib/plug/conn/adapter.ex
|
@@ -1,7 +1,8 @@
|
1
1
|
# In this file we check if at least one of the adapters are implemented.
|
2
2
|
# Since right now we only support cowboy, the check is straight-forward.
|
3
3
|
unless Code.ensure_loaded?(:cowboy_req) do
|
4
|
- raise "cannot compile Plug because the :cowboy application is not available"
|
4
|
+ raise "cannot compile Plug because the :cowboy application is not available. " <>
|
5
|
+ "Please ensure it is listed as a dependency before the plug one."
|
5
6
|
end
|
6
7
|
|
7
8
|
defmodule Plug.Conn.Adapter do
|
changed
lib/plug/mime.ex
|
@@ -48,10 +48,8 @@ defmodule Plug.MIME do
|
48
48
|
|
49
49
|
@spec type(String.t) :: String.t
|
50
50
|
|
51
|
- lc { type, exts } inlist mapping do
|
52
|
- lc ext inlist exts do
|
53
|
- def type(unquote(ext)), do: unquote(type)
|
54
|
- end
|
51
|
+ for { type, exts } <- mapping, ext <- exts do
|
52
|
+ def type(unquote(ext)), do: unquote(type)
|
55
53
|
end
|
56
54
|
|
57
55
|
def type(_ext), do: @default_type
|
|
@@ -73,7 +71,7 @@ defmodule Plug.MIME do
|
73
71
|
|
74
72
|
# entry/1
|
75
73
|
|
76
|
- lc { type, exts } inlist mapping do
|
74
|
+ for { type, exts } <- mapping do
|
77
75
|
defp entry(unquote(type)), do: unquote(exts)
|
78
76
|
end
|
changed
mix.exs
|
@@ -3,8 +3,8 @@ defmodule Plug.Mixfile do
|
3
3
|
|
4
4
|
def project do
|
5
5
|
[app: :plug,
|
6
|
- version: "0.4.2",
|
7
|
- elixir: "~> 0.13.1",
|
6
|
+ version: "0.4.3",
|
7
|
+ elixir: "~> 0.13.2",
|
8
8
|
deps: deps,
|
9
9
|
package: package,
|
10
10
|
description: "A specification and conveniences for composable " <>
|
|
@@ -25,7 +25,7 @@ defmodule Plug.Mixfile do
|
25
25
|
end
|
26
26
|
|
27
27
|
defp package do
|
28
|
- [licenses: ["Apache 2"],
|
29
|
- links: [{"Github", "https://github.com/elixir-lang/plug"}]]
|
28
|
+ %{licenses: ["Apache 2"],
|
29
|
+ links: %{"Github" => "https://github.com/elixir-lang/plug"}}
|
30
30
|
end
|
31
31
|
end
|