Skip to content

Commit

Permalink
Prepare for v1.3.0.beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Aug 2, 2018
1 parent bf8b930 commit 2bd56aa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,14 @@
# Hanami::Router
Rack compatible HTTP router for Ruby

## v1.3.0.beta1 (unreleased)
## v1.3.0.beta1 - 2018-08-08
### Added
- [Luca Guidi] Official support for JRuby 9.2.0.0
- [Gustavo Caso] Introduce `Hanami::Middleware::BodyParser` Rack middleware to parse payload of non-GET HTTP requests.

### Deprecated
- [Alfonso Uceda] Deprecate `Hanami::Router.new(force_ssl: true)`. Use webserver (eg. Nginx), Rack middleware (eg. `rack-ssl`), or another strategy to force HTTPS connection.
- [Gustavo Caso] Deprecate `Hanami::Router.new(body_parsers: [:json])`. Use `Hanami::Middleware::BodyParser` instead.

## v1.2.0 - 2018-04-11

Expand Down
10 changes: 5 additions & 5 deletions lib/hanami/middleware/body_parser.rb
Expand Up @@ -3,22 +3,22 @@

module Hanami
module Middleware
# @since x.x.x
# @since 1.3.0
# @api private
class BodyParser
# @since x.x.x
# @since 1.3.0
# @api private
CONTENT_TYPE = 'CONTENT_TYPE'.freeze

# @since x.x.x
# @since 1.3.0
# @api private
MEDIA_TYPE_MATCHER = /\s*[;,]\s*/.freeze

# @since x.x.x
# @since 1.3.0
# @api private
RACK_INPUT = 'rack.input'.freeze

# @since x.x.x
# @since 1.3.0
# @api private
ROUTER_PARAMS = 'router.params'.freeze

Expand Down
6 changes: 3 additions & 3 deletions lib/hanami/middleware/body_parser/json_parser.rb
Expand Up @@ -3,10 +3,10 @@
module Hanami
module Middleware
class BodyParser
# @since x.x.x
# @since 1.3.0
# @api private
class JsonParser < Parser
# @since x.x.x
# @since 1.3.0
# @api private
def mime_types
['application/json', 'application/vnd.api+json']
Expand All @@ -20,7 +20,7 @@ def mime_types
#
# @raise [Hanami::Middleware::BodyParser::BodyParsingError] when the body can't be parsed.
#
# @since x.x.x
# @since 1.3.0
# @api private
def parse(body)
Hanami::Utils::Json.parse(body)
Expand Down
14 changes: 7 additions & 7 deletions lib/hanami/middleware/body_parser/parser.rb
Expand Up @@ -8,17 +8,17 @@ class BodyParser
# Body parsing error
# This is raised when parser fails to parse the body
#
# @since x.x.x
# @since 1.3.0
class BodyParsingError < Hanami::Routing::Parsing::BodyParsingError
end

# @since x.x.x
# @since 1.3.0
class UnknownParserError < Hanami::Routing::Parsing::UnknownParserError
end

# @since x.x.x
# @since 1.3.0
class Parser
# @since x.x.x
# @since 1.3.0
# @api private
def self.for(parser)
case parser
Expand All @@ -30,18 +30,18 @@ def self.for(parser)
end
end

# @since x.x.x
# @since 1.3.0
def mime_types
raise NotImplementedError
end

# @since x.x.x
# @since 1.3.0
def parse(body)
body
end

private
# @since x.x.x
# @since 1.3.0
# @api private
def self.require_parser(parser)
require "hanami/middleware/body_parser/#{ parser }_parser"
Expand Down

0 comments on commit 2bd56aa

Please sign in to comment.