From e8ab18f0e8d1ce45a1d4a7eeb5ea68483ec50bf4 Mon Sep 17 00:00:00 2001 From: syeopite Date: Tue, 3 Aug 2021 10:58:02 -0700 Subject: [PATCH] Add more macros for adding routes of HTTP methods --- src/invidious/routing.cr | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index f26fb1d4..1fd3477d 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -1,13 +1,11 @@ module Invidious::Routing - macro get(path, controller, method = :handle) - get {{ path }} do |env| - {{ controller }}.{{ method.id }}(env) - end - end + {% for http_method in {"get", "post", "delete", "options", "patch", "put", "head"} %} - macro post(path, controller, method = :handle) - post {{ path }} do |env| - {{ controller }}.{{ method.id }}(env) + macro {{http_method.id}}(path, controller, method = :handle) + {{http_method.id}} \{{ path }} do |env| + \{{ controller }}.\{{ method.id }}(env) + end end - end + + {% end %} end