Skip to content

Commit

Permalink
Merge pull request #11 from aristotelesbr/development
Browse files Browse the repository at this point in the history
Fix post Resques to parse post params
  • Loading branch information
aristotelesbr authored Nov 25, 2023
2 parents ac5e0b2 + 485492e commit 2fe8402
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.4] - 2023-25-11

### Fixed

- Internal docmentation methods
- Fix `post_params` from Resquest router class

### Added

- Add basic documentation for usage. See [README.md](README.md) for more details.

## [0.1.3] - 2023-24-11

## [0.1.2] - 2023-23-11

### Added
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lennarb (0.1.3)
lennarb (0.1.4)
colorize (~> 1.1)
puma (~> 6.4)
rack (~> 3.0, >= 3.0.8)
Expand Down
28 changes: 27 additions & 1 deletion lib/lenna/router/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def headers
content_type = env['CONTENT_TYPE']
@headers ||= env.select { |k, _| k.start_with?('HTTP_') }
.transform_keys { |k| format_header_name(k) }

@headers['Content-Type'] = content_type if content_type
@headers
end
Expand All @@ -62,6 +62,11 @@ def parse_json_body
{}
end

# This method parses the body params.
#
# @return [Hash] the request body params
#
# @api private
def parse_body_params
case media_type
when 'application/json'
Expand All @@ -73,6 +78,27 @@ def parse_body_params
end
end

# This method parses the post params.
#
# @return [Hash] the request post params
#
# @api private
def post_params
@post_params ||=
if body_content.empty?
{}
else
::Rack::Utils.parse_nested_query(body_content)
end
end

# This method formats the header name.
#
# @param name [String] the header name
#
# @return [String] the formatted header name
#
# @api private
def format_header_name(name)
name.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-')
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lennarb/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Lennarb
VERSION = '0.1.3'
VERSION = '0.1.4'

public_constant :VERSION
end

0 comments on commit 2fe8402

Please sign in to comment.