diff --git a/package.json b/package.json index 1d15f76..6675e0b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "test:general": "npm run test:general:dev && npm run test:general:prod", "test:general:dev": "cd tests/general && CRYSTAL_ENV=TEST crystal spec e2e/* --error-trace", "test:general:prod": "cd tests/general && CRYSTAL_ENV=production CLOSE_PROCESS=true crystal spec e2e/* --error-trace", - "test": "npm run test:general && npm run test:websocket", + "test": "npm run test:general && npm run test:server && npm run test:websocket", "start": "cd tests/general && crystal src/general.cr --error-trace", "start:dev": "cd tests/general && crystal src/general.cr --error-trace", "start:prod": "cd tests/general && CRYSTAL_ENV=Production crystal src/general.cr --error-trace", diff --git a/src/handlers/index.cr b/src/handlers/index.cr index 7df6a99..7de6a98 100644 --- a/src/handlers/index.cr +++ b/src/handlers/index.cr @@ -1,3 +1,5 @@ require "./route_handler" require "./request_handler" require "./injector_handler" + + \ No newline at end of file diff --git a/src/handlers/request_handler.cr b/src/handlers/request_handler.cr index 42d9db4..cde0870 100644 --- a/src/handlers/request_handler.cr +++ b/src/handlers/request_handler.cr @@ -6,6 +6,7 @@ require "../constants" require "../helpers/index" require "../generics/index" require "../aliases" +require "../tuples/all" module Shivneri module Handlers @@ -13,6 +14,7 @@ module Shivneri include HELPER include MODEL include GENERIC + include TUPLE class RequestHandler < PostHandler getter query, context, route_match_info, session_provider, component_data diff --git a/src/hashes/http_method.cr b/src/hashes/http_method.cr deleted file mode 100644 index 1eaacbc..0000000 --- a/src/hashes/http_method.cr +++ /dev/null @@ -1,13 +0,0 @@ -module Shivneri - module HASHES - HTTP_METHOD = { - "get" => "GET", - "post" => "POST", - "put" => "PUT", - "patch" => "PATCH", - "delete" => "DELETE", - "options" => "OPTIONS", - "head" => "HEAD", - } - end -end diff --git a/src/hashes/index.cr b/src/hashes/index.cr index c3d51ab..50f5a4d 100644 --- a/src/hashes/index.cr +++ b/src/hashes/index.cr @@ -1,2 +1 @@ require "./mime_type" -require "./http_method" diff --git a/src/model/worker_info.cr b/src/model/worker_info.cr index 92107b8..5b07237 100644 --- a/src/model/worker_info.cr +++ b/src/model/worker_info.cr @@ -13,10 +13,15 @@ module Shivneri # expectedQuery?: any; # expectedBody?: any; - def initialize(workerName : String, httpMethods : Array(String), @workerProc) + def initialize(workerName : String, http_methods : Array(String), @workerProc) @name = workerName @pattern = "/#{workerName}" - @methodsAllowed = httpMethods.size == 0 ? HTTP_METHOD.values : httpMethods + @methodsAllowed = http_methods + if (http_methods.size == 0) + HTTP_METHOD.each_value do |value| + @methodsAllowed.push(value) + end + end end def to_json diff --git a/src/tuples/all.cr b/src/tuples/all.cr new file mode 100644 index 0000000..ce89a95 --- /dev/null +++ b/src/tuples/all.cr @@ -0,0 +1 @@ +require "./http_method" diff --git a/src/tuples/folder_map.cr b/src/tuples/folder_map.cr deleted file mode 100644 index e69de29..0000000 diff --git a/src/tuples/http_method.cr b/src/tuples/http_method.cr new file mode 100644 index 0000000..5d195f2 --- /dev/null +++ b/src/tuples/http_method.cr @@ -0,0 +1,13 @@ +module Shivneri + module TUPLE + HTTP_METHOD = { + get: "GET", + post: "POST", + put: "PUT", + patch: "PATCH", + delete: "DELETE", + options: "OPTIONS", + head: "HEAD", + } + end +end