Add get,post,put,head,delete,patch to easily perform requests

This commit is contained in:
Sdogruyol 2016-04-10 14:36:06 +03:00
parent 85b52dab77
commit ee61ecfdf1

View file

@ -4,6 +4,7 @@ require "kemal"
TIME_TO_SLEEP = 0.00001 TIME_TO_SLEEP = 0.00001
APP_PORT = 1989 APP_PORT = 1989
APP_ENV = "test" APP_ENV = "test"
APP_URL = "http://localhost:#{APP_PORT}"
Kemal.config.env = APP_ENV Kemal.config.env = APP_ENV
Kemal.config.port = APP_PORT Kemal.config.port = APP_PORT
@ -21,3 +22,9 @@ Spec.after_each do
Kemal.config.server.close Kemal.config.server.close
end end
end end
{% for method in %w(get post put head delete patch) %}
def {{method.id}}(path, headers : HTTP::Headers? = nil, body : String? = nil)
HTTP::Client.{{method.id}}(APP_URL + path, headers, body)
end
{% end %}