-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb4ac86
commit c426320
Showing
139 changed files
with
2,839 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
log/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: bundle exec hanami server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require "hanami/rake_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# auto_register: false | ||
# frozen_string_literal: true | ||
|
||
require 'hanami/action' | ||
|
||
class HanamiTest::Action < Hanami::Action | ||
class RecordNotFound < StandardError; end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Extensions | ||
class Create < HanamiTest::Action | ||
def handle(_request, response) | ||
response.body = [{ name: 'my-ext-1' }].to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Extensions | ||
class Index < HanamiTest::Action | ||
def handle(_request, response) | ||
response.body = { message: 'created' }.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class Index < HanamiTest::Action | ||
format :json | ||
|
||
def handle(_request, response) | ||
list = [ | ||
{ | ||
name: 'file.png', | ||
tags: [], # Keep this empty to check empty array is accepted | ||
}, | ||
] | ||
|
||
response.body = list.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class Show < HanamiTest::Action | ||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class Upload < HanamiTest::Action | ||
# format :form | ||
|
||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class UploadMultiple < HanamiTest::Action | ||
# format :multipart | ||
|
||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
spec/apps/hanami/app/actions/images/upload_multiple_nested.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class UploadMultipleNested < HanamiTest::Action | ||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Images | ||
class UploadNested < HanamiTest::Action | ||
def handle(_request, response) | ||
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADklEQVQIW2P4DwUMlDEA98A/wTjPQBoAAAAASUVORK5CYII=' | ||
.unpack('m').first | ||
|
||
response.format = :png | ||
response.body = png | ||
response.headers.merge!( | ||
{ | ||
'Content-Type' => 'image/png', | ||
'Content-Disposition' => 'inline', | ||
} | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module SecretItems | ||
class Index < HanamiTest::Action | ||
format :json | ||
|
||
def handle(_request, response) | ||
response.body = { items: ['secrets'] }.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Create < TableAction | ||
format :json | ||
|
||
def handle(request, response) | ||
if request.params[:name].blank? || request.params[:name] == 'some_invalid_name' | ||
response.status = 422 | ||
response.body = { error: 'invalid name parameter' }.to_json | ||
else | ||
response.status = 201 | ||
response.body = find_table.to_json | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Destroy < TableAction | ||
def handle(request, response) | ||
response.format = :json | ||
if request.params[:no_content] | ||
response.status = 202 | ||
else | ||
response.body = find_table(request.params[:id]).to_json | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Index < TableAction | ||
def handle(request, response) | ||
response.headers['X-Cursor'] = 100 | ||
|
||
response.format = :json | ||
|
||
response.body = if request.params[:show_columns] | ||
[find_table('42')].to_json | ||
else | ||
[find_table].to_json | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class Show < TableAction | ||
format :json | ||
|
||
def handle(request, response) | ||
response.body = find_table(request.params[:id]).to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module HanamiTest | ||
module Actions | ||
module Tables | ||
class TableAction < HanamiTest::Action | ||
APIKEY = 'k0kubun'.freeze | ||
|
||
include TableRepository | ||
|
||
handle_exception RecordNotFound => :handle_not_fount_error | ||
|
||
before :authenticate | ||
|
||
private | ||
|
||
def handle_not_fount_error(_request, _response, _exception) | ||
halt 404, { message: 'not found' }.to_json | ||
end | ||
|
||
def authenticate(request, response) | ||
return unless request.get_header('AUTHORIZATION') != APIKEY | ||
|
||
response.format = :json | ||
halt 401, { message: 'Unauthorized' }.to_json | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.