- Enhancements
- Require Plug 1.8+ and drop Cowboy dependency
- Bug fixes
- [Mix] Fix gen.resource task for Elixir 1.9
- Bug fixes
- [Mix] Fix gen.resource task for Elixir 1.9
- Enhancements
- [Generator] Add
namespace
option.
- [Generator] Add
- Enhancements
- Replace
dir
option in generator task withpath
option that can set the target filename
- Replace
- Bug fixes
- Update plug version in mix file and README
-
Enhancements
- Make resource gen task work in umbrella projects
- Add switch to generate resource with no tutorial comments
-
Backwards incompatible changes
- The resource
init/2
callback will send 500 for any return value other than:ok
- Change
allow_missing_post
default tofalse
- Require Plug 1.3
- The resource
-
Enhancements
- Improve documentation of REST callbacks
- Add documentation to resource template
-
Bug fixes
- Fix typespec for handler
state
vsrest_state
- Fix spec of
content_types_accepted
callback - Show
nil
return type inexpires
andgenerate_etag
callbacks - List only the functions that should be imported into each Resource
- Fix typespec for handler
- Bug fixes
- Fix allowed_methods in resource template
-
Enhancements
- The
resource
macro will work with any Plug module - Plug.Builder can be used inside Resources
- Add
:private
and:assigns
options to resource macro
- The
-
Backwards incompatible changes
- The
resource
macro splits theoptions
into options for the Plug, and options for the macro. Changestate: true, host: "host."
totrue, host: "host."
known_methods
defaults can be changed in the application config, and are no longer an option for the Router or Resource plugs- Require all resource handlers to be Plugs
- The
- Bug fixes
- Fix current time function fallback
-
Enhancements
Plug.Debugger
will show errors if it's used
-
Backwards incompatible changes
- The resource
init/2
callback will only terminate when:stop
is returned. All other value will continue REST execution. - Exceptions raised inside a
PlugRest.Resource
will not be caught
- The resource
-
Enhancements
- Add
known_methods
option to the Router which sets the default known methods for resources - Add Mix task to generate a resource module
- Add
-
Backwards incompatible changes
- Routers must call
match
anddispatch
manually, so that the plug pipeline can work as expected PlugRest.Resource.upgrade/3
takes a list of options instead of just handler state
- Routers must call
-
Enhancements
- Export overridable
init/1
andcall/2
callbacks so that each Resource can act as a Plug module. - Make dynamic path parameters available in
conn.params
- Handler callbacks can manually set the response body with
put_rest_body/2
- Export overridable
-
Bug fixes
- Terminate correctly when a resource callback wants to
:stop
- Terminate correctly when a resource callback wants to
-
Backwards incompatible changes
- Remove
read_path_params/1
(useconn.params
instead) - Move private connection accessors from
Conn
toResource
module and change the specs
- Remove
- Bug fixes
- Fix bug where setting conn.resp_body directly had no effect on output
- Bug fixes
- Simplify resource behaviour callback typespecs
-
Enhancements
- Content handler callbacks (like
to_html
) can return{:file, filename}
for the body, which will usePlug.Conn.send_file/3
to send the response - The resource macro can restrict route matches to a specific host.
- Content handler callbacks (like
-
Backwards incompatible changes
- The default values of
expires
,generate_etag
, andlast_modified
arenil
instead of:undefined
- Resource initial state is set with an option keyword list:
resource "/path", Handler, state: :ok
- The default values of
- Bug fixes
- Fix pattern match for accept language wildcard
- Fix
last_modified
pattern match inif_modified_since
- Enhancements
- Make current time function configurable, for testing purposes
- Bug fixes
- Fix compiler warnings when using /glob/*_rest paths
-
Enhancements
- Save chosen media type from accept header into private conn storage
-
Bug fixes
- Fix content negotiation when media type params do not match
- Let content types provided correctly match all or none accept-extensions
- Ditto for content types accepted
-
Enhancements
- Send 404 response by default when no routes match
-
Deprecations
- Using
match _ do
in your Router to handle 404 responses is no longer necessary and will show a compiler warning when present
- Using
- Bug fixes
- Fix specs for some resource callback return types
- Enhancements
- Import
Plug.Conn
when usingPlugRest.Resource
- Import
- Backwards incompatible changes
- Dynamic path segments are no longer available in
conn.params
- Dynamic path segments are no longer available in
- Enhancements
- Add
using
macro toPlugRest.Resource
that adopts the module's behaviour and importsPlugRest.Conn.read_path_params/1
- Add
-
Enhancements
- Use
PlugRest.Conn.read_path_params/1
to access values of dynamic segments of resource paths
- Use
-
Deprecations
- Deprecate
conn.params
for url params in favor ofread_url_params/2
- Deprecate
- Enhancements
- Content provided callbacks (like
to_html
) can return{:chunked, enumerable}
for the body
- Content provided callbacks (like
- Enhancements
- Return 500 response if resource handler does not exist
-
Enhancements
- Use
Plug.Router
internally and make match macros available - Make compatible with Elixir 1.2
- Use
-
Bug fixes
- Ensure that resource handler modules are loaded before use
-
Backwards incompatible changes
- Change
use PlugRest
touse PlugRest.Router
- Change
- Definition of a Plug router pipeline and
resource
macro - Passes test suite designed for cowboy_rest