diff --git a/tests/projects/balancer_app/pages/different_datacenter.py b/tests/projects/balancer_app/pages/different_datacenter.py
index 2e4a4522a..8b295b026 100644
--- a/tests/projects/balancer_app/pages/different_datacenter.py
+++ b/tests/projects/balancer_app/pages/different_datacenter.py
@@ -7,7 +7,7 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
if TYPE_CHECKING:
@@ -15,6 +15,7 @@
class Page(PageHandler):
+ @router.get()
async def get_page(self):
free_server = get_server(self, 'free')
free_server.datacenter = 'dc1'
@@ -37,6 +38,7 @@ async def get_page(self):
self.text = result.data
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/different_datacenter_async.py b/tests/projects/balancer_app/pages/different_datacenter_async.py
index 0ce370535..bc4d6cba4 100644
--- a/tests/projects/balancer_app/pages/different_datacenter_async.py
+++ b/tests/projects/balancer_app/pages/different_datacenter_async.py
@@ -3,11 +3,12 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
class Page(PageHandler):
+ @router.get()
async def get_page(self):
free_server = get_server(self, 'free')
free_server.datacenter = 'dc1'
@@ -30,6 +31,7 @@ async def get_page(self):
self.text = result.data
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/no_available_backend.py b/tests/projects/balancer_app/pages/no_available_backend.py
index cb508d91e..eaffdcd96 100644
--- a/tests/projects/balancer_app/pages/no_available_backend.py
+++ b/tests/projects/balancer_app/pages/no_available_backend.py
@@ -2,10 +2,12 @@
from http_client.request_response import NoAvailableServerException
from frontik import handler, media_types
+from frontik.handler import router
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('no_available_backend', {}, []))
@@ -20,6 +22,7 @@ async def request_with_processing() -> None:
self.run_task(request_with_processing())
check_all_requests_done(self, 'no_available_backend')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/no_available_backend_async.py b/tests/projects/balancer_app/pages/no_available_backend_async.py
index df72c5849..fd0b95b25 100644
--- a/tests/projects/balancer_app/pages/no_available_backend_async.py
+++ b/tests/projects/balancer_app/pages/no_available_backend_async.py
@@ -2,10 +2,12 @@
from http_client.request_response import NoAvailableServerException
from frontik import handler, media_types
+from frontik.handler import router
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('no_available_backend', {}, []))
@@ -22,6 +24,7 @@ async def get_page(self):
check_all_requests_done(self, 'no_available_backend')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/no_retry_error.py b/tests/projects/balancer_app/pages/no_retry_error.py
index 254048f2f..636628578 100644
--- a/tests/projects/balancer_app/pages/no_retry_error.py
+++ b/tests/projects/balancer_app/pages/no_retry_error.py
@@ -1,11 +1,13 @@
from http_client.balancing import Upstream
from frontik import handler, media_types
+from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('no_retry_error', {}, [get_server(self, 'broken')]))
@@ -17,6 +19,7 @@ async def get_page(self):
check_all_requests_done(self, 'no_retry_error')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/no_retry_error_async.py b/tests/projects/balancer_app/pages/no_retry_error_async.py
index f3cbf2113..c52073edd 100644
--- a/tests/projects/balancer_app/pages/no_retry_error_async.py
+++ b/tests/projects/balancer_app/pages/no_retry_error_async.py
@@ -1,11 +1,13 @@
from http_client.balancing import Upstream
from frontik import handler, media_types
+from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('no_retry_error_async', {}, [get_server(self, 'broken')]),
@@ -20,6 +22,7 @@ async def get_page(self):
check_all_requests_done(self, 'no_retry_error_async')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/no_retry_timeout.py b/tests/projects/balancer_app/pages/no_retry_timeout.py
index e90329627..0b8699f30 100644
--- a/tests/projects/balancer_app/pages/no_retry_timeout.py
+++ b/tests/projects/balancer_app/pages/no_retry_timeout.py
@@ -3,11 +3,13 @@
from http_client.balancing import Upstream
from frontik import handler, media_types
+from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('no_retry_timeout', {}, [get_server(self, 'broken')]),
@@ -21,6 +23,7 @@ async def get_page(self):
check_all_requests_done(self, 'no_retry_timeout')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/no_retry_timeout_async.py b/tests/projects/balancer_app/pages/no_retry_timeout_async.py
index 2e658e6c2..ce6a494ea 100644
--- a/tests/projects/balancer_app/pages/no_retry_timeout_async.py
+++ b/tests/projects/balancer_app/pages/no_retry_timeout_async.py
@@ -3,11 +3,13 @@
from http_client.balancing import Upstream, UpstreamConfig
from frontik import handler, media_types
+from frontik.handler import router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.upstreams['no_retry_timeout_async'] = Upstream(
'no_retry_timeout_async',
@@ -33,6 +35,7 @@ async def get_page(self):
check_all_requests_done(self, 'no_retry_timeout_async')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/profile_with_retry.py b/tests/projects/balancer_app/pages/profile_with_retry.py
index 9fe84b5b4..d23a1cb1b 100644
--- a/tests/projects/balancer_app/pages/profile_with_retry.py
+++ b/tests/projects/balancer_app/pages/profile_with_retry.py
@@ -2,11 +2,12 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
class Page(PageHandler):
+ @router.get()
async def get_page(self):
servers = [get_server(self, 'broken'), get_server(self, 'normal')]
upstream_config = {
@@ -27,6 +28,7 @@ async def get_page(self):
self.text = result.data
+ @router.put()
async def put_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/profile_without_retry.py b/tests/projects/balancer_app/pages/profile_without_retry.py
index ebf45f2e2..0f6026450 100644
--- a/tests/projects/balancer_app/pages/profile_without_retry.py
+++ b/tests/projects/balancer_app/pages/profile_without_retry.py
@@ -1,11 +1,12 @@
from http_client.balancing import Upstream, UpstreamConfig
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
class Page(PageHandler):
+ @router.get()
async def get_page(self):
servers = [get_server(self, 'broken'), get_server(self, 'normal')]
upstream_config = {
@@ -26,6 +27,7 @@ async def get_page(self):
self.text = result.data
+ @router.put()
async def put_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/requests_count.py b/tests/projects/balancer_app/pages/requests_count.py
index b24f47de3..ad022b689 100644
--- a/tests/projects/balancer_app/pages/requests_count.py
+++ b/tests/projects/balancer_app/pages/requests_count.py
@@ -3,12 +3,13 @@
from http_client.balancing import Upstream
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done, check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(Upstream('requests_count', {}, [get_server(self, 'normal')]))
self.text = ''
@@ -28,6 +29,7 @@ async def request_with_processing() -> None:
await asyncio.sleep(0.1)
check_all_servers_were_occupied(self, 'requests_count')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = str(self.application.upstream_manager.upstreams['requests_count'].servers[0].stat_requests)
diff --git a/tests/projects/balancer_app/pages/requests_count_async.py b/tests/projects/balancer_app/pages/requests_count_async.py
index 8faf47c2f..71d0a844b 100644
--- a/tests/projects/balancer_app/pages/requests_count_async.py
+++ b/tests/projects/balancer_app/pages/requests_count_async.py
@@ -3,12 +3,13 @@
from http_client.balancing import Upstream
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done, check_all_servers_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('requests_count_async', {}, [get_server(self, 'normal')]),
@@ -32,6 +33,7 @@ async def get_page(self):
check_all_requests_done(self, 'requests_count_async')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
servers = self.application.upstream_manager.upstreams['requests_count_async'].servers
diff --git a/tests/projects/balancer_app/pages/retry_connect.py b/tests/projects/balancer_app/pages/retry_connect.py
index 50cc66e26..895cf2279 100644
--- a/tests/projects/balancer_app/pages/retry_connect.py
+++ b/tests/projects/balancer_app/pages/retry_connect.py
@@ -2,13 +2,14 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.util import gather_list
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect', {}, [get_server(self, 'free'), get_server(self, 'normal')]),
@@ -30,6 +31,7 @@ async def get_page(self):
self.text = self.text + result.data
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_connect_async.py b/tests/projects/balancer_app/pages/retry_connect_async.py
index 96eeb9acf..608cddb12 100644
--- a/tests/projects/balancer_app/pages/retry_connect_async.py
+++ b/tests/projects/balancer_app/pages/retry_connect_async.py
@@ -4,12 +4,13 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect_async', {}, [get_server(self, 'free'), get_server(self, 'normal')]),
@@ -36,6 +37,7 @@ async def make_request() -> None:
check_all_servers_were_occupied(self, 'retry_connect_async')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_connect_timeout.py b/tests/projects/balancer_app/pages/retry_connect_timeout.py
index 10654af98..f8754a5d4 100644
--- a/tests/projects/balancer_app/pages/retry_connect_timeout.py
+++ b/tests/projects/balancer_app/pages/retry_connect_timeout.py
@@ -2,13 +2,14 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.util import gather_list
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect_timeout', {}, [get_server(self, 'normal')]),
@@ -30,6 +31,7 @@ async def get_page(self):
self.text = self.text + result.data
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_connect_timeout_async.py b/tests/projects/balancer_app/pages/retry_connect_timeout_async.py
index 11288a303..0b9cb7972 100644
--- a/tests/projects/balancer_app/pages/retry_connect_timeout_async.py
+++ b/tests/projects/balancer_app/pages/retry_connect_timeout_async.py
@@ -4,12 +4,13 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_connect_timeout', {}, [get_server(self, 'normal')]),
@@ -36,6 +37,7 @@ async def make_request() -> None:
check_all_servers_were_occupied(self, 'retry_connect_timeout')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_count_limit.py b/tests/projects/balancer_app/pages/retry_count_limit.py
index c3eb9384e..49abd97e8 100644
--- a/tests/projects/balancer_app/pages/retry_count_limit.py
+++ b/tests/projects/balancer_app/pages/retry_count_limit.py
@@ -1,11 +1,12 @@
from http_client.balancing import Upstream, UpstreamConfig
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.instances import find_free_port
from tests.projects.balancer_app import get_server_with_port
class Page(PageHandler):
+ @router.get()
async def get_page(self):
upstream = Upstream(
'retry_count_limit',
diff --git a/tests/projects/balancer_app/pages/retry_count_limit_async.py b/tests/projects/balancer_app/pages/retry_count_limit_async.py
index d1936a685..bdce4682a 100644
--- a/tests/projects/balancer_app/pages/retry_count_limit_async.py
+++ b/tests/projects/balancer_app/pages/retry_count_limit_async.py
@@ -1,11 +1,12 @@
from http_client.balancing import Upstream, UpstreamConfig
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.instances import find_free_port
from tests.projects.balancer_app import get_server_with_port
class Page(PageHandler):
+ @router.get()
async def get_page(self):
upstream = Upstream(
'retry_count_limit_async',
diff --git a/tests/projects/balancer_app/pages/retry_error.py b/tests/projects/balancer_app/pages/retry_error.py
index 5c9649806..75ccf855a 100644
--- a/tests/projects/balancer_app/pages/retry_error.py
+++ b/tests/projects/balancer_app/pages/retry_error.py
@@ -2,13 +2,14 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.util import gather_list
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_error', {}, [get_server(self, 'broken'), get_server(self, 'normal')]),
@@ -30,6 +31,7 @@ async def get_page(self):
self.text = self.text + result.data
+ @router.put()
async def put_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_error_async.py b/tests/projects/balancer_app/pages/retry_error_async.py
index 0e801b9f4..a71209e3e 100644
--- a/tests/projects/balancer_app/pages/retry_error_async.py
+++ b/tests/projects/balancer_app/pages/retry_error_async.py
@@ -4,12 +4,13 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_error_async', {}, [get_server(self, 'broken'), get_server(self, 'normal')]),
@@ -36,6 +37,7 @@ async def make_request() -> None:
check_all_servers_were_occupied(self, 'retry_error_async')
+ @router.put()
async def put_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_non_idempotent_503.py b/tests/projects/balancer_app/pages/retry_non_idempotent_503.py
index 22fe36b3a..79557956c 100644
--- a/tests/projects/balancer_app/pages/retry_non_idempotent_503.py
+++ b/tests/projects/balancer_app/pages/retry_non_idempotent_503.py
@@ -2,13 +2,14 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.util import gather_list
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(PageHandler):
+ @router.get()
async def get_page(self):
upstream_config = {Upstream.DEFAULT_PROFILE: UpstreamConfig(retry_policy={503: {'idempotent': 'true'}})}
self.application.upstream_manager.update_upstream(
@@ -33,6 +34,7 @@ async def get_page(self):
check_all_requests_done(self, 'retry_non_idempotent_503')
check_all_requests_done(self, 'do_not_retry_non_idempotent_503')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_non_idempotent_503_async.py b/tests/projects/balancer_app/pages/retry_non_idempotent_503_async.py
index 06b8d7f37..7ad5f3294 100644
--- a/tests/projects/balancer_app/pages/retry_non_idempotent_503_async.py
+++ b/tests/projects/balancer_app/pages/retry_non_idempotent_503_async.py
@@ -4,12 +4,13 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(PageHandler):
+ @router.get()
async def get_page(self):
upstream_config = {Upstream.DEFAULT_PROFILE: UpstreamConfig(retry_policy={503: {'idempotent': 'true'}})}
self.application.upstream_manager.update_upstream(
@@ -42,6 +43,7 @@ async def post_without_retry() -> None:
check_all_requests_done(self, 'retry_non_idempotent_503_async')
check_all_requests_done(self, 'do_not_retry_non_idempotent_503_async')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_on_timeout.py b/tests/projects/balancer_app/pages/retry_on_timeout.py
index 4e6f4d7d8..1dd952787 100644
--- a/tests/projects/balancer_app/pages/retry_on_timeout.py
+++ b/tests/projects/balancer_app/pages/retry_on_timeout.py
@@ -2,12 +2,13 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_on_timeout', {}, [get_server(self, 'broken'), get_server(self, 'normal')]),
@@ -28,6 +29,7 @@ async def get_page(self):
check_all_requests_done(self, 'retry_on_timeout')
+ @router.delete()
async def delete_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/retry_on_timeout_async.py b/tests/projects/balancer_app/pages/retry_on_timeout_async.py
index fdca6769b..d357b4cb8 100644
--- a/tests/projects/balancer_app/pages/retry_on_timeout_async.py
+++ b/tests/projects/balancer_app/pages/retry_on_timeout_async.py
@@ -2,12 +2,13 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.update_upstream(
Upstream('retry_on_timeout_async', {}, [get_server(self, 'broken'), get_server(self, 'normal')]),
@@ -28,6 +29,7 @@ async def get_page(self):
check_all_requests_done(self, 'retry_on_timeout_async')
+ @router.delete()
async def delete_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/slow_start.py b/tests/projects/balancer_app/pages/slow_start.py
index 638eaf3c0..dc8d37e86 100644
--- a/tests/projects/balancer_app/pages/slow_start.py
+++ b/tests/projects/balancer_app/pages/slow_start.py
@@ -3,12 +3,13 @@
from http_client.balancing import Server, Upstream, UpstreamConfig
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done, check_all_servers_were_occupied
class Page(PageHandler):
+ @router.get()
async def get_page(self):
server = get_server(self, 'normal')
server.weight = 5
@@ -45,6 +46,7 @@ async def get_page(self):
self.text = str(server.stat_requests + server_slow_start.stat_requests)
check_all_requests_done(self, 'slow_start')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = str(self.application.upstream_manager.upstreams['slow_start'].servers[0].stat_requests)
diff --git a/tests/projects/balancer_app/pages/slow_start_async.py b/tests/projects/balancer_app/pages/slow_start_async.py
index bdef22815..0e0528e80 100644
--- a/tests/projects/balancer_app/pages/slow_start_async.py
+++ b/tests/projects/balancer_app/pages/slow_start_async.py
@@ -3,12 +3,13 @@
from http_client.balancing import Server, Upstream, UpstreamConfig
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
from tests.projects.balancer_app.pages import check_all_requests_done
class Page(PageHandler):
+ @router.get()
async def get_page(self):
server = get_server(self, 'normal')
server.weight = 5
@@ -42,6 +43,7 @@ async def make_request(delay: float = 0) -> None:
check_all_requests_done(self, 'slow_start_async')
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
servers = self.application.upstream_manager.upstreams['slow_start_async'].servers
diff --git a/tests/projects/balancer_app/pages/speculative_no_retry.py b/tests/projects/balancer_app/pages/speculative_no_retry.py
index 5c74d45b5..bf0771355 100644
--- a/tests/projects/balancer_app/pages/speculative_no_retry.py
+++ b/tests/projects/balancer_app/pages/speculative_no_retry.py
@@ -1,11 +1,12 @@
from http_client.balancing import Upstream
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.upstreams['speculative_no_retry'] = Upstream('speculative_no_retry', {}, [])
self.application.upstream_manager.update_upstream(
@@ -27,6 +28,7 @@ async def get_page(self):
self.text = result.data
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/balancer_app/pages/speculative_retry.py b/tests/projects/balancer_app/pages/speculative_retry.py
index b45473653..d5d6ba195 100644
--- a/tests/projects/balancer_app/pages/speculative_retry.py
+++ b/tests/projects/balancer_app/pages/speculative_retry.py
@@ -2,11 +2,12 @@
from tornado.web import HTTPError
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from tests.projects.balancer_app import get_server
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.application.upstream_manager.upstreams['speculative_retry'] = Upstream('speculative_no_retry', {}, [])
self.application.upstream_manager.update_upstream(
@@ -27,6 +28,7 @@ async def get_page(self):
self.text = result.data
+ @router.put()
async def put_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'result'
diff --git a/tests/projects/broken_balancer_app/pages/no_retry_error.py b/tests/projects/broken_balancer_app/pages/no_retry_error.py
index a7d8b7c68..6935ac281 100644
--- a/tests/projects/broken_balancer_app/pages/no_retry_error.py
+++ b/tests/projects/broken_balancer_app/pages/no_retry_error.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.post()
async def post_page(self):
raise HTTPError(500, 'something went wrong, no retry')
diff --git a/tests/projects/broken_balancer_app/pages/no_retry_error_async.py b/tests/projects/broken_balancer_app/pages/no_retry_error_async.py
index a7d8b7c68..6935ac281 100644
--- a/tests/projects/broken_balancer_app/pages/no_retry_error_async.py
+++ b/tests/projects/broken_balancer_app/pages/no_retry_error_async.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.post()
async def post_page(self):
raise HTTPError(500, 'something went wrong, no retry')
diff --git a/tests/projects/broken_balancer_app/pages/no_retry_timeout.py b/tests/projects/broken_balancer_app/pages/no_retry_timeout.py
index db5ceb704..c6fc9efa0 100644
--- a/tests/projects/broken_balancer_app/pages/no_retry_timeout.py
+++ b/tests/projects/broken_balancer_app/pages/no_retry_timeout.py
@@ -1,9 +1,11 @@
import time
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.post()
async def post_page(self):
self.add_timeout(time.time() + 2, self.finish_group.add(self.check_finished(self.timeout_callback)))
diff --git a/tests/projects/broken_balancer_app/pages/no_retry_timeout_async.py b/tests/projects/broken_balancer_app/pages/no_retry_timeout_async.py
index 141ad7ef3..8e0857379 100644
--- a/tests/projects/broken_balancer_app/pages/no_retry_timeout_async.py
+++ b/tests/projects/broken_balancer_app/pages/no_retry_timeout_async.py
@@ -1,9 +1,11 @@
import asyncio
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.post()
async def post_page(self):
await asyncio.sleep(2)
diff --git a/tests/projects/broken_balancer_app/pages/profile_with_retry.py b/tests/projects/broken_balancer_app/pages/profile_with_retry.py
index 8f4eb8011..da3919d04 100644
--- a/tests/projects/broken_balancer_app/pages/profile_with_retry.py
+++ b/tests/projects/broken_balancer_app/pages/profile_with_retry.py
@@ -1,8 +1,10 @@
from tornado.web import HTTPError
from frontik import handler
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.put()
async def put_page(self):
raise HTTPError(503, 'broken')
diff --git a/tests/projects/broken_balancer_app/pages/profile_without_retry.py b/tests/projects/broken_balancer_app/pages/profile_without_retry.py
index 8f4eb8011..da3919d04 100644
--- a/tests/projects/broken_balancer_app/pages/profile_without_retry.py
+++ b/tests/projects/broken_balancer_app/pages/profile_without_retry.py
@@ -1,8 +1,10 @@
from tornado.web import HTTPError
from frontik import handler
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.put()
async def put_page(self):
raise HTTPError(503, 'broken')
diff --git a/tests/projects/broken_balancer_app/pages/retry_connect.py b/tests/projects/broken_balancer_app/pages/retry_connect.py
index ddc2d3e9b..077a85a3d 100644
--- a/tests/projects/broken_balancer_app/pages/retry_connect.py
+++ b/tests/projects/broken_balancer_app/pages/retry_connect.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.post()
async def post_page(self):
raise HTTPError(503, 'broken, retry')
diff --git a/tests/projects/broken_balancer_app/pages/retry_connect_async.py b/tests/projects/broken_balancer_app/pages/retry_connect_async.py
index ddc2d3e9b..077a85a3d 100644
--- a/tests/projects/broken_balancer_app/pages/retry_connect_async.py
+++ b/tests/projects/broken_balancer_app/pages/retry_connect_async.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.post()
async def post_page(self):
raise HTTPError(503, 'broken, retry')
diff --git a/tests/projects/broken_balancer_app/pages/retry_error.py b/tests/projects/broken_balancer_app/pages/retry_error.py
index 9941e106a..a765be851 100644
--- a/tests/projects/broken_balancer_app/pages/retry_error.py
+++ b/tests/projects/broken_balancer_app/pages/retry_error.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.put()
async def put_page(self):
raise HTTPError(503, 'broken, retry')
diff --git a/tests/projects/broken_balancer_app/pages/retry_error_async.py b/tests/projects/broken_balancer_app/pages/retry_error_async.py
index 9941e106a..a765be851 100644
--- a/tests/projects/broken_balancer_app/pages/retry_error_async.py
+++ b/tests/projects/broken_balancer_app/pages/retry_error_async.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.put()
async def put_page(self):
raise HTTPError(503, 'broken, retry')
diff --git a/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503.py b/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503.py
index ddc2d3e9b..077a85a3d 100644
--- a/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503.py
+++ b/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.post()
async def post_page(self):
raise HTTPError(503, 'broken, retry')
diff --git a/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503_async.py b/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503_async.py
index ddc2d3e9b..077a85a3d 100644
--- a/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503_async.py
+++ b/tests/projects/broken_balancer_app/pages/retry_non_idempotent_503_async.py
@@ -1,8 +1,9 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.post()
async def post_page(self):
raise HTTPError(503, 'broken, retry')
diff --git a/tests/projects/broken_balancer_app/pages/retry_on_timeout.py b/tests/projects/broken_balancer_app/pages/retry_on_timeout.py
index 1d11fe73c..69a6306a2 100644
--- a/tests/projects/broken_balancer_app/pages/retry_on_timeout.py
+++ b/tests/projects/broken_balancer_app/pages/retry_on_timeout.py
@@ -1,9 +1,11 @@
import time
from frontik import handler, media_types
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.delete()
async def delete_page(self):
self.add_timeout(time.time() + 2, self.finish_group.add(self.check_finished(self.timeout_callback)))
diff --git a/tests/projects/broken_balancer_app/pages/retry_on_timeout_async.py b/tests/projects/broken_balancer_app/pages/retry_on_timeout_async.py
index dfaec75ed..d85888fba 100644
--- a/tests/projects/broken_balancer_app/pages/retry_on_timeout_async.py
+++ b/tests/projects/broken_balancer_app/pages/retry_on_timeout_async.py
@@ -1,9 +1,11 @@
import asyncio
from frontik import handler, media_types
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.delete()
async def delete_page(self):
await asyncio.sleep(2)
diff --git a/tests/projects/broken_balancer_app/pages/speculative_no_retry.py b/tests/projects/broken_balancer_app/pages/speculative_no_retry.py
index d37014608..96998e4f5 100644
--- a/tests/projects/broken_balancer_app/pages/speculative_no_retry.py
+++ b/tests/projects/broken_balancer_app/pages/speculative_no_retry.py
@@ -3,9 +3,11 @@
from tornado.web import HTTPError
from frontik import handler
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.post()
async def post_page(self):
await asyncio.sleep(0.8)
raise HTTPError(500, 'broken')
diff --git a/tests/projects/broken_balancer_app/pages/speculative_retry.py b/tests/projects/broken_balancer_app/pages/speculative_retry.py
index d265bce2e..14bdae1f8 100644
--- a/tests/projects/broken_balancer_app/pages/speculative_retry.py
+++ b/tests/projects/broken_balancer_app/pages/speculative_retry.py
@@ -3,9 +3,11 @@
from tornado.web import HTTPError
from frontik import handler
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.put()
async def put_page(self):
await asyncio.sleep(0.8)
raise HTTPError(503, 'broken, retry')
diff --git a/tests/projects/consul_mock_app/pages/call_deregistration_stat.py b/tests/projects/consul_mock_app/pages/call_deregistration_stat.py
index c04588c15..8f062d55e 100644
--- a/tests/projects/consul_mock_app/pages/call_deregistration_stat.py
+++ b/tests/projects/consul_mock_app/pages/call_deregistration_stat.py
@@ -3,13 +3,14 @@
import json
from typing import TYPE_CHECKING
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
if TYPE_CHECKING:
from tests.projects.consul_mock_app import TestApplication
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_status(200)
self.application: TestApplication
diff --git a/tests/projects/consul_mock_app/pages/call_deregistration_stat_async.py b/tests/projects/consul_mock_app/pages/call_deregistration_stat_async.py
index c04588c15..8f062d55e 100644
--- a/tests/projects/consul_mock_app/pages/call_deregistration_stat_async.py
+++ b/tests/projects/consul_mock_app/pages/call_deregistration_stat_async.py
@@ -3,13 +3,14 @@
import json
from typing import TYPE_CHECKING
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
if TYPE_CHECKING:
from tests.projects.consul_mock_app import TestApplication
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_status(200)
self.application: TestApplication
diff --git a/tests/projects/consul_mock_app/pages/call_registration_stat.py b/tests/projects/consul_mock_app/pages/call_registration_stat.py
index 5f12903c1..054849fd3 100644
--- a/tests/projects/consul_mock_app/pages/call_registration_stat.py
+++ b/tests/projects/consul_mock_app/pages/call_registration_stat.py
@@ -3,13 +3,14 @@
import json
from typing import TYPE_CHECKING
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
if TYPE_CHECKING:
from tests.projects.consul_mock_app import TestApplication
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_status(200)
self.application: TestApplication
diff --git a/tests/projects/consul_mock_app/pages/call_registration_stat_async.py b/tests/projects/consul_mock_app/pages/call_registration_stat_async.py
index 5f12903c1..054849fd3 100644
--- a/tests/projects/consul_mock_app/pages/call_registration_stat_async.py
+++ b/tests/projects/consul_mock_app/pages/call_registration_stat_async.py
@@ -3,13 +3,14 @@
import json
from typing import TYPE_CHECKING
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
if TYPE_CHECKING:
from tests.projects.consul_mock_app import TestApplication
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_status(200)
self.application: TestApplication
diff --git a/tests/projects/consul_mock_app/pages/deregister.py b/tests/projects/consul_mock_app/pages/deregister.py
index 86a8f36bb..e420b1395 100644
--- a/tests/projects/consul_mock_app/pages/deregister.py
+++ b/tests/projects/consul_mock_app/pages/deregister.py
@@ -2,7 +2,7 @@
from typing import TYPE_CHECKING
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
if TYPE_CHECKING:
from tests.projects.consul_mock_app import TestApplication
@@ -13,14 +13,17 @@ def __init__(self, *args, **kwargs):
self.application: TestApplication
super().__init__(*args, **kwargs)
+ @router.get()
async def get_page(self):
self.set_status(200)
self.application.deregistration_call_counter['get_page'] += 1
+ @router.put()
async def put_page(self):
self.set_status(200)
self.application.deregistration_call_counter['put_page'] += 1
+ @router.post()
async def post_page(self):
self.set_status(200)
self.application.deregistration_call_counter['post_page'] += 1
diff --git a/tests/projects/consul_mock_app/pages/v1/agent/service/register.py b/tests/projects/consul_mock_app/pages/v1/agent/service/register.py
index 4d2bcaf02..c464f9d58 100644
--- a/tests/projects/consul_mock_app/pages/v1/agent/service/register.py
+++ b/tests/projects/consul_mock_app/pages/v1/agent/service/register.py
@@ -2,7 +2,7 @@
from typing import TYPE_CHECKING
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
if TYPE_CHECKING:
from tests.projects.consul_mock_app import TestApplication
@@ -13,14 +13,17 @@ def __init__(self, *args, **kwargs):
self.application: TestApplication
super().__init__(*args, **kwargs)
+ @router.get()
async def get_page(self):
self.set_status(200)
self.application.registration_call_counter['get_page'] += 1
+ @router.put()
async def put_page(self):
self.set_status(200)
self.application.registration_call_counter['put_page'] += 1
+ @router.post()
async def post_page(self):
self.set_status(200)
self.application.registration_call_counter['post_page'] += 1
diff --git a/tests/projects/consul_mock_app/pages/v1/kv/host/hostname/weight/weight.py b/tests/projects/consul_mock_app/pages/v1/kv/host/hostname/weight/weight.py
index 944033805..6d6aaa2ef 100644
--- a/tests/projects/consul_mock_app/pages/v1/kv/host/hostname/weight/weight.py
+++ b/tests/projects/consul_mock_app/pages/v1/kv/host/hostname/weight/weight.py
@@ -1,16 +1,19 @@
import json
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_header('X-Consul-Index', 1)
self.text = json.dumps([{'Value': 'NTU=', 'CreateIndex': 1, 'ModifyIndex': 1}])
self.set_status(200)
+ @router.put()
async def put_page(self):
self.set_status(200)
+ @router.post()
async def post_page(self):
self.set_status(200)
diff --git a/tests/projects/consul_mock_app/pages/v1/kv/upstream/upstream.py b/tests/projects/consul_mock_app/pages/v1/kv/upstream/upstream.py
index 2c0a2fb69..82d3de99b 100644
--- a/tests/projects/consul_mock_app/pages/v1/kv/upstream/upstream.py
+++ b/tests/projects/consul_mock_app/pages/v1/kv/upstream/upstream.py
@@ -1,16 +1,19 @@
import json
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_header('X-Consul-Index', 1)
self.text = json.dumps([{'Value': None, 'CreateIndex': 1, 'ModifyIndex': 1}])
self.set_status(200)
+ @router.put()
async def put_page(self):
self.set_status(200)
+ @router.post()
async def post_page(self):
self.set_status(200)
diff --git a/tests/projects/no_debug_app/pages/basic_auth.py b/tests/projects/no_debug_app/pages/basic_auth.py
index 424ea89d4..c45cfa0ad 100644
--- a/tests/projects/no_debug_app/pages/basic_auth.py
+++ b/tests/projects/no_debug_app/pages/basic_auth.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.require_debug_access('user', 'god')
self.json.put({'authenticated': True})
diff --git a/tests/projects/no_debug_app/pages/basic_auth_async.py b/tests/projects/no_debug_app/pages/basic_auth_async.py
index 424ea89d4..c45cfa0ad 100644
--- a/tests/projects/no_debug_app/pages/basic_auth_async.py
+++ b/tests/projects/no_debug_app/pages/basic_auth_async.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.require_debug_access('user', 'god')
self.json.put({'authenticated': True})
diff --git a/tests/projects/no_debug_app/pages/check_workers_count_down.py b/tests/projects/no_debug_app/pages/check_workers_count_down.py
index 939b5deb2..77d6da6b3 100644
--- a/tests/projects/no_debug_app/pages/check_workers_count_down.py
+++ b/tests/projects/no_debug_app/pages/check_workers_count_down.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.text = str(self.application.init_workers_count_down.value)
diff --git a/tests/projects/no_debug_app/pages/check_workers_count_down_async.py b/tests/projects/no_debug_app/pages/check_workers_count_down_async.py
index 939b5deb2..77d6da6b3 100644
--- a/tests/projects/no_debug_app/pages/check_workers_count_down_async.py
+++ b/tests/projects/no_debug_app/pages/check_workers_count_down_async.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.text = str(self.application.init_workers_count_down.value)
diff --git a/tests/projects/no_debug_app/pages/jinja_no_environment.py b/tests/projects/no_debug_app/pages/jinja_no_environment.py
index 1db2ef63a..e15dd443a 100644
--- a/tests/projects/no_debug_app/pages/jinja_no_environment.py
+++ b/tests/projects/no_debug_app/pages/jinja_no_environment.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_template('empty.html')
self.json.put({'x': 'y'})
diff --git a/tests/projects/no_debug_app/pages/jinja_no_environment_async.py b/tests/projects/no_debug_app/pages/jinja_no_environment_async.py
index 1db2ef63a..e15dd443a 100644
--- a/tests/projects/no_debug_app/pages/jinja_no_environment_async.py
+++ b/tests/projects/no_debug_app/pages/jinja_no_environment_async.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_template('empty.html')
self.json.put({'x': 'y'})
diff --git a/tests/projects/no_debug_app/pages/recursion.py b/tests/projects/no_debug_app/pages/recursion.py
index 4b05faf2a..585400fc9 100644
--- a/tests/projects/no_debug_app/pages/recursion.py
+++ b/tests/projects/no_debug_app/pages/recursion.py
@@ -1,7 +1,9 @@
from frontik import handler, media_types
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
n = int(self.get_argument('n'))
if n > 0:
diff --git a/tests/projects/no_debug_app/pages/recursion_async.py b/tests/projects/no_debug_app/pages/recursion_async.py
index 6d0012345..bdfcc1559 100644
--- a/tests/projects/no_debug_app/pages/recursion_async.py
+++ b/tests/projects/no_debug_app/pages/recursion_async.py
@@ -1,7 +1,9 @@
from frontik import handler, media_types
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
n = int(self.get_argument('n'))
if n > 0:
diff --git a/tests/projects/no_debug_app/pages/simple.py b/tests/projects/no_debug_app/pages/simple.py
index aaf21ce54..fa67aca62 100644
--- a/tests/projects/no_debug_app/pages/simple.py
+++ b/tests/projects/no_debug_app/pages/simple.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('simple.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/no_debug_app/pages/simple_async.py b/tests/projects/no_debug_app/pages/simple_async.py
index aaf21ce54..fa67aca62 100644
--- a/tests/projects/no_debug_app/pages/simple_async.py
+++ b/tests/projects/no_debug_app/pages/simple_async.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('simple.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/re_app/pages/handler_404.py b/tests/projects/re_app/pages/handler_404.py
index 0243a0ab3..dbd80f5c1 100644
--- a/tests/projects/re_app/pages/handler_404.py
+++ b/tests/projects/re_app/pages/handler_404.py
@@ -1,7 +1,8 @@
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.text = '404'
self.set_status(404)
diff --git a/tests/projects/re_app/pages/id_param.py b/tests/projects/re_app/pages/id_param.py
index 153c604d6..13243efb7 100644
--- a/tests/projects/re_app/pages/id_param.py
+++ b/tests/projects/re_app/pages/id_param.py
@@ -1,9 +1,11 @@
import lxml.etree as etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('id_param.xsl')
self.doc.put(etree.Element('id', value=self.get_argument('id', 'wrong')))
diff --git a/tests/projects/re_app/pages/jinja_custom_environment.py b/tests/projects/re_app/pages/jinja_custom_environment.py
index f39980797..ffd1e189e 100644
--- a/tests/projects/re_app/pages/jinja_custom_environment.py
+++ b/tests/projects/re_app/pages/jinja_custom_environment.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_template('jinja_custom_environment.html')
self.json.put({})
diff --git a/tests/projects/re_app/pages/reverse_url.py b/tests/projects/re_app/pages/reverse_url.py
index a4a0fc170..1c1c38e77 100644
--- a/tests/projects/re_app/pages/reverse_url.py
+++ b/tests/projects/re_app/pages/reverse_url.py
@@ -1,7 +1,8 @@
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
if self.get_argument('fail_args', 'false') != 'false':
self.text = self.reverse_url('two_ids', 1)
diff --git a/tests/projects/re_app/pages/sentry_not_configured.py b/tests/projects/re_app/pages/sentry_not_configured.py
index 49331f107..74f5dad02 100644
--- a/tests/projects/re_app/pages/sentry_not_configured.py
+++ b/tests/projects/re_app/pages/sentry_not_configured.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
assert not hasattr(self, 'get_sentry_logger')
diff --git a/tests/projects/re_app/pages/simple.py b/tests/projects/re_app/pages/simple.py
index aaf21ce54..fa67aca62 100644
--- a/tests/projects/re_app/pages/simple.py
+++ b/tests/projects/re_app/pages/simple.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('simple.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/api/2/store.py b/tests/projects/test_app/pages/api/2/store.py
index 533ffcf85..0eaeaa1a5 100644
--- a/tests/projects/test_app/pages/api/2/store.py
+++ b/tests/projects/test_app/pages/api/2/store.py
@@ -2,18 +2,22 @@
import json
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
exceptions = []
+ @router.post()
async def post_page(self):
message = gzip.decompress(self.request.body).decode('utf8')
sentry_event = json.loads(message.split('\n')[-1])
Page.exceptions.append(sentry_event)
+ @router.get()
async def get_page(self):
self.json.put({'exceptions': Page.exceptions})
+ @router.delete()
async def delete_page(self):
Page.exceptions = []
diff --git a/tests/projects/test_app/pages/arguments.py b/tests/projects/test_app/pages/arguments.py
index ef90e2660..8c19b6aad 100644
--- a/tests/projects/test_app/pages/arguments.py
+++ b/tests/projects/test_app/pages/arguments.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.json.put({'тест': self.get_argument('param')})
diff --git a/tests/projects/test_app/pages/arguments_async.py b/tests/projects/test_app/pages/arguments_async.py
index ef90e2660..8c19b6aad 100644
--- a/tests/projects/test_app/pages/arguments_async.py
+++ b/tests/projects/test_app/pages/arguments_async.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.json.put({'тест': self.get_argument('param')})
diff --git a/tests/projects/test_app/pages/async_group/group.py b/tests/projects/test_app/pages/async_group/group.py
index 1bf791c8a..3c7f6fc17 100644
--- a/tests/projects/test_app/pages/async_group/group.py
+++ b/tests/projects/test_app/pages/async_group/group.py
@@ -1,8 +1,10 @@
import frontik.handler
+from frontik.handler import router
from frontik.util import gather_dict
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
ensure_callback_is_async = False
fail_callback = self.get_argument('fail_callback', 'false') == 'true'
@@ -43,5 +45,6 @@ async def group_task() -> None:
self.run_task(group_task())
+ @router.post()
async def post_page(self):
self.json.put({self.get_argument('data'): 'yay'})
diff --git a/tests/projects/test_app/pages/async_group/group_async.py b/tests/projects/test_app/pages/async_group/group_async.py
index 04295a44b..201be77c8 100644
--- a/tests/projects/test_app/pages/async_group/group_async.py
+++ b/tests/projects/test_app/pages/async_group/group_async.py
@@ -1,9 +1,11 @@
from typing import Any
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
fail_callback = self.get_argument('fail_callback', 'false') == 'true'
fail_request = self.get_argument('fail_request', 'false') == 'true'
@@ -35,5 +37,6 @@ async def task() -> Any:
self.json.put({'future_callback_result': result['4'].data['4']})
self.json.put({'final_callback_called': True})
+ @router.post()
async def post_page(self):
self.json.put({self.get_argument('data'): 'yay'})
diff --git a/tests/projects/test_app/pages/async_group/group_with_futures.py b/tests/projects/test_app/pages/async_group/group_with_futures.py
index 845db9278..168a87b23 100644
--- a/tests/projects/test_app/pages/async_group/group_with_futures.py
+++ b/tests/projects/test_app/pages/async_group/group_with_futures.py
@@ -1,10 +1,12 @@
from tornado.concurrent import Future
import frontik.handler
+from frontik.handler import router
from frontik.util import gather_dict
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
future: Future = Future()
diff --git a/tests/projects/test_app/pages/async_group/group_with_futures_async.py b/tests/projects/test_app/pages/async_group/group_with_futures_async.py
index 8817c8e22..21617e8cf 100644
--- a/tests/projects/test_app/pages/async_group/group_with_futures_async.py
+++ b/tests/projects/test_app/pages/async_group/group_with_futures_async.py
@@ -1,9 +1,11 @@
from tornado.concurrent import Future
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
future: Future = Future()
diff --git a/tests/projects/test_app/pages/async_group/not_waited_failed_requests.py b/tests/projects/test_app/pages/async_group/not_waited_failed_requests.py
index 47322d784..dcbeed707 100644
--- a/tests/projects/test_app/pages/async_group/not_waited_failed_requests.py
+++ b/tests/projects/test_app/pages/async_group/not_waited_failed_requests.py
@@ -1,9 +1,10 @@
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
data: dict = {}
+ @router.get()
async def get_page(self):
if self.request.method == 'HEAD':
await self.head_page()
@@ -24,12 +25,15 @@ async def get_page(self):
async def head_page(self) -> None:
self._record_failed_request({'head_failed': True})
+ @router.post()
async def post_page(self):
self._record_failed_request({'post_failed': True})
+ @router.put()
async def put_page(self):
self._record_failed_request({'put_failed': True})
+ @router.delete()
async def delete_page(self):
self._record_failed_request({'delete_failed': True})
diff --git a/tests/projects/test_app/pages/async_group/not_waited_failed_requests_async.py b/tests/projects/test_app/pages/async_group/not_waited_failed_requests_async.py
index 47322d784..dcbeed707 100644
--- a/tests/projects/test_app/pages/async_group/not_waited_failed_requests_async.py
+++ b/tests/projects/test_app/pages/async_group/not_waited_failed_requests_async.py
@@ -1,9 +1,10 @@
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
data: dict = {}
+ @router.get()
async def get_page(self):
if self.request.method == 'HEAD':
await self.head_page()
@@ -24,12 +25,15 @@ async def get_page(self):
async def head_page(self) -> None:
self._record_failed_request({'head_failed': True})
+ @router.post()
async def post_page(self):
self._record_failed_request({'post_failed': True})
+ @router.put()
async def put_page(self):
self._record_failed_request({'put_failed': True})
+ @router.delete()
async def delete_page(self):
self._record_failed_request({'delete_failed': True})
diff --git a/tests/projects/test_app/pages/async_group/not_waited_requests.py b/tests/projects/test_app/pages/async_group/not_waited_requests.py
index 27b0d5cd5..aa77e5415 100644
--- a/tests/projects/test_app/pages/async_group/not_waited_requests.py
+++ b/tests/projects/test_app/pages/async_group/not_waited_requests.py
@@ -1,11 +1,12 @@
import asyncio
-from frontik.handler import AbortAsyncGroup, PageHandler
+from frontik.handler import AbortAsyncGroup, PageHandler, router
class Page(PageHandler):
data: dict = {}
+ @router.get()
async def get_page(self):
if not self.data:
self.json.put({'get': True})
@@ -32,12 +33,15 @@ async def coro(self) -> None:
except AbortAsyncGroup:
self.record_request({'delete_cancelled': True})
+ @router.post()
async def post_page(self):
self.record_request({'post_made': True})
+ @router.put()
async def put_page(self):
self.record_request({'put_made': True})
+ @router.delete()
async def delete_page(self):
self.record_request({'delete_made': True})
diff --git a/tests/projects/test_app/pages/async_group/not_waited_requests_async.py b/tests/projects/test_app/pages/async_group/not_waited_requests_async.py
index 7dd408e1d..6163284a4 100644
--- a/tests/projects/test_app/pages/async_group/not_waited_requests_async.py
+++ b/tests/projects/test_app/pages/async_group/not_waited_requests_async.py
@@ -1,11 +1,12 @@
import asyncio
-from frontik.handler import AbortAsyncGroup, PageHandler
+from frontik.handler import AbortAsyncGroup, PageHandler, router
class Page(PageHandler):
data: dict = {}
+ @router.get()
async def get_page(self):
if not self.data:
self.json.put({'get': True})
@@ -32,12 +33,15 @@ async def coro(self) -> None:
except AbortAsyncGroup:
self.record_request({'delete_cancelled': True})
+ @router.post()
async def post_page(self):
self.record_request({'post_made': True})
+ @router.put()
async def put_page(self):
self.record_request({'put_made': True})
+ @router.delete()
async def delete_page(self):
self.record_request({'delete_made': True})
diff --git a/tests/projects/test_app/pages/broken_workflow.py b/tests/projects/test_app/pages/broken_workflow.py
index 31d4aff2b..b8abc22b9 100644
--- a/tests/projects/test_app/pages/broken_workflow.py
+++ b/tests/projects/test_app/pages/broken_workflow.py
@@ -1,10 +1,11 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.util import gather_list
class Page(PageHandler):
+ @router.get()
async def get_page(self):
port = int(self.get_argument('port'))
diff --git a/tests/projects/test_app/pages/cdata.py b/tests/projects/test_app/pages/cdata.py
index 2a901464a..744a6cc80 100644
--- a/tests/projects/test_app/pages/cdata.py
+++ b/tests/projects/test_app/pages/cdata.py
@@ -1,11 +1,13 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
CDATA_XML = b']]>'
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path)
@@ -15,6 +17,7 @@ async def get_page(self):
self.doc.put(xpath)
+ @router.post()
async def post_page(self):
parser = etree.XMLParser(encoding='UTF-8', strip_cdata=False)
root = etree.XML(CDATA_XML, parser)
diff --git a/tests/projects/test_app/pages/cdata_async.py b/tests/projects/test_app/pages/cdata_async.py
index 2fe279603..89dbc4e60 100644
--- a/tests/projects/test_app/pages/cdata_async.py
+++ b/tests/projects/test_app/pages/cdata_async.py
@@ -1,11 +1,13 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
CDATA_XML = b']]>'
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path)
self.doc.put(result.data)
@@ -14,6 +16,7 @@ async def get_page(self):
assert len(xpath) == 1
assert etree.tostring(xpath[0]) == CDATA_XML
+ @router.post()
async def post_page(self):
parser = etree.XMLParser(encoding='UTF-8', strip_cdata=False)
root = etree.XML(CDATA_XML, parser)
diff --git a/tests/projects/test_app/pages/compose_doc.py b/tests/projects/test_app/pages/compose_doc.py
index 2f3c332b3..fb36532d2 100644
--- a/tests/projects/test_app/pages/compose_doc.py
+++ b/tests/projects/test_app/pages/compose_doc.py
@@ -3,9 +3,11 @@
import frontik.handler
from frontik import media_types
from frontik.doc import Doc
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
invalid_xml = self.get_argument('invalid', 'false')
@@ -14,6 +16,7 @@ async def get_page(self):
self.doc.put(result.to_etree_element())
self.doc.put(Doc('c'))
+ @router.post()
async def post_page(self):
invalid_xml = self.get_argument('invalid', 'false') == 'true'
diff --git a/tests/projects/test_app/pages/compose_doc_async.py b/tests/projects/test_app/pages/compose_doc_async.py
index d86737cb4..6e650e638 100644
--- a/tests/projects/test_app/pages/compose_doc_async.py
+++ b/tests/projects/test_app/pages/compose_doc_async.py
@@ -3,9 +3,11 @@
import frontik.handler
from frontik import media_types
from frontik.doc import Doc
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
invalid_xml = self.get_argument('invalid', 'false')
@@ -13,6 +15,7 @@ async def get_page(self):
self.doc.put(self.post_url(self.request.host, self.request.path, data={'invalid': invalid_xml}))
self.doc.put(Doc('c'))
+ @router.post()
async def post_page(self):
invalid_xml = self.get_argument('invalid', 'false') == 'true'
diff --git a/tests/projects/test_app/pages/debug.py b/tests/projects/test_app/pages/debug.py
index 3f2227bbd..2089e4e14 100644
--- a/tests/projects/test_app/pages/debug.py
+++ b/tests/projects/test_app/pages/debug.py
@@ -1,9 +1,11 @@
from lxml.builder import E
from frontik import handler, media_types
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
self.log.debug('debug: starting debug page')
@@ -43,11 +45,13 @@ def _inner() -> None:
self.log.debug('testing utf-8 text output', extra={'_text': 'some\nmultiline\nюникод\ndebug'})
self.log.debug('testing unicode text output', extra={'_text': 'some\nmultiline\nюникод\ndebug'})
+ @router.post()
async def post_page(self):
self.log.debug('this page returns json')
self.json.put({'param1': 'value', 'param2': 'тест', 'тест': 'value'})
+ @router.put()
async def put_page(self):
content_type = self.get_argument('type')
diff --git a/tests/projects/test_app/pages/error_yield.py b/tests/projects/test_app/pages/error_yield.py
index 61a4ec8ed..b31f02383 100644
--- a/tests/projects/test_app/pages/error_yield.py
+++ b/tests/projects/test_app/pages/error_yield.py
@@ -1,4 +1,5 @@
import frontik.handler
+from frontik.handler import router
async def some_async_function(handler: frontik.handler.PageHandler) -> float:
@@ -7,8 +8,10 @@ async def some_async_function(handler: frontik.handler.PageHandler) -> float:
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.finish_group.add_future(some_async_function(self)) # type: ignore
+ @router.post()
async def post_page(self):
self.text = 'result'
diff --git a/tests/projects/test_app/pages/error_yield_async.py b/tests/projects/test_app/pages/error_yield_async.py
index 41197ba86..cc1147cb9 100644
--- a/tests/projects/test_app/pages/error_yield_async.py
+++ b/tests/projects/test_app/pages/error_yield_async.py
@@ -1,10 +1,13 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
await self.post_url(self.request.host, self.request.path)
return 1 / 0
+ @router.post()
async def post_page(self):
self.text = 'result'
diff --git a/tests/projects/test_app/pages/fail_fast/__init__.py b/tests/projects/test_app/pages/fail_fast/__init__.py
index b7384b75a..eb3656a57 100644
--- a/tests/projects/test_app/pages/fail_fast/__init__.py
+++ b/tests/projects/test_app/pages/fail_fast/__init__.py
@@ -1,6 +1,6 @@
-from fastapi import APIRouter, Depends
+from fastapi import Depends
-from frontik.handler import HTTPErrorWithPostprocessors, PageHandler, get_current_handler
+from frontik.handler import HTTPErrorWithPostprocessors, PageHandler, get_current_handler, router
from frontik.util import gather_dict
@@ -9,9 +9,7 @@ def get_page_preprocessor(handler: PageHandler = Depends(get_current_handler)) -
class Page(PageHandler):
- router = APIRouter()
-
- @router.get('/', dependencies=[Depends(get_page_preprocessor)])
+ @router.get(dependencies=[Depends(get_page_preprocessor)])
async def get_page(self):
fail_fast = self.get_argument('fail_fast', 'false') == 'true'
@@ -47,6 +45,7 @@ def get_page_fail_fast(self, failed_future):
self.set_status(403)
self.finish_with_postprocessors()
+ @router.post()
async def post_page(self):
if self.get_argument('fail_fast_default', 'false') == 'true':
results = await gather_dict(
@@ -63,11 +62,13 @@ async def post_page(self):
else:
self.json.put({'POST': self.get_argument('param')})
+ @router.put()
async def put_page(self):
# Testing parse_on_error=True
self.json.put({'error': 'forbidden'})
raise HTTPErrorWithPostprocessors(int(self.get_argument('code')))
+ @router.delete()
async def delete_page(self):
# Testing invalid return values
if self.get_argument('invalid_dict_value', 'false') == 'true':
diff --git a/tests/projects/test_app/pages/fail_fast/fail_fast_without_done.py b/tests/projects/test_app/pages/fail_fast/fail_fast_without_done.py
index 286137288..b50624dc0 100644
--- a/tests/projects/test_app/pages/fail_fast/fail_fast_without_done.py
+++ b/tests/projects/test_app/pages/fail_fast/fail_fast_without_done.py
@@ -1,14 +1,16 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
await self.post_url(self.request.host, self.request.path, fail_fast=True)
def get_page_fail_fast(self, failed_future):
raise HTTPError(401)
+ @router.post()
async def post_page(self):
raise HTTPError(403)
diff --git a/tests/projects/test_app/pages/fail_fast/future.py b/tests/projects/test_app/pages/fail_fast/future.py
index 96ef60f62..33d98c37b 100644
--- a/tests/projects/test_app/pages/fail_fast/future.py
+++ b/tests/projects/test_app/pages/fail_fast/future.py
@@ -1,11 +1,12 @@
from tornado.concurrent import Future
from tornado.ioloop import IOLoop
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.util import gather_dict
class Page(PageHandler):
+ @router.get()
async def get_page(self):
fail_future = self.get_argument('fail_future', 'false') == 'true'
diff --git a/tests/projects/test_app/pages/fail_fast/with_postprocessors.py b/tests/projects/test_app/pages/fail_fast/with_postprocessors.py
index e321cc5a4..c8273b4ea 100644
--- a/tests/projects/test_app/pages/fail_fast/with_postprocessors.py
+++ b/tests/projects/test_app/pages/fail_fast/with_postprocessors.py
@@ -1,9 +1,10 @@
from tornado.web import HTTPError
-from frontik.handler import HTTPErrorWithPostprocessors, PageHandler
+from frontik.handler import HTTPErrorWithPostprocessors, PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path, fail_fast=True)
self.json.put(result.data)
@@ -12,5 +13,6 @@ def get_page_fail_fast(self, failed_future):
self.json.put({'error': 'some_error'})
raise HTTPErrorWithPostprocessors()
+ @router.post()
async def post_page(self):
raise HTTPError(403)
diff --git a/tests/projects/test_app/pages/finish.py b/tests/projects/test_app/pages/finish.py
index ccd823dab..a8b3cd9af 100644
--- a/tests/projects/test_app/pages/finish.py
+++ b/tests/projects/test_app/pages/finish.py
@@ -1,9 +1,10 @@
from tornado.web import Finish
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
throw = self.get_argument('throw', 'true') == 'true'
code = int(self.get_argument('code', '200'))
diff --git a/tests/projects/test_app/pages/finish_204.py b/tests/projects/test_app/pages/finish_204.py
index 87bc023d8..358ae2d02 100644
--- a/tests/projects/test_app/pages/finish_204.py
+++ b/tests/projects/test_app/pages/finish_204.py
@@ -1,7 +1,8 @@
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.write('data')
self.set_status(204)
diff --git a/tests/projects/test_app/pages/finish_with_postprocessors.py b/tests/projects/test_app/pages/finish_with_postprocessors.py
index 37e2c6dcc..54bf71e37 100644
--- a/tests/projects/test_app/pages/finish_with_postprocessors.py
+++ b/tests/projects/test_app/pages/finish_with_postprocessors.py
@@ -1,7 +1,7 @@
from lxml import etree
from tornado.web import HTTPError
-from frontik.handler import FinishWithPostprocessors, PageHandler
+from frontik.handler import FinishWithPostprocessors, PageHandler, router
class Page(PageHandler):
@@ -13,6 +13,7 @@ def pp(handler):
self.add_postprocessor(pp)
+ @router.get()
async def get_page(self):
content_type = self.get_argument('type')
@@ -34,5 +35,6 @@ async def fail_request() -> None:
raise FinishWithPostprocessors()
+ @router.post()
async def post_page(self):
pass
diff --git a/tests/projects/test_app/pages/handler/check_finished.py b/tests/projects/test_app/pages/handler/check_finished.py
index ef201953e..39afb2231 100644
--- a/tests/projects/test_app/pages/handler/check_finished.py
+++ b/tests/projects/test_app/pages/handler/check_finished.py
@@ -1,9 +1,11 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
result = 'Callback not called'
+ @router.get()
async def get_page(self):
# Callback must never be called
def callback():
diff --git a/tests/projects/test_app/pages/handler/delete.py b/tests/projects/test_app/pages/handler/delete.py
index 24bdd7601..75611916c 100644
--- a/tests/projects/test_app/pages/handler/delete.py
+++ b/tests/projects/test_app/pages/handler/delete.py
@@ -1,16 +1,20 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.delete_url('http://' + self.request.host, self.request.path, data={'data': 'true'})
if not result.failed:
self.json.put(result.data)
+ @router.post()
async def post_page(self):
result = await self.delete_url('http://backend', self.request.path, fail_fast=True)
if not result.failed:
self.json.put(result.data)
+ @router.delete()
async def delete_page(self):
self.json.put({'delete': self.get_argument('data')})
diff --git a/tests/projects/test_app/pages/handler/head.py b/tests/projects/test_app/pages/handler/head.py
index c3ca72137..fb27eb603 100644
--- a/tests/projects/test_app/pages/handler/head.py
+++ b/tests/projects/test_app/pages/handler/head.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_header('X-Foo', 'Bar')
self.text = 'response body must be empty for HEAD requests'
diff --git a/tests/projects/test_app/pages/handler/head_url.py b/tests/projects/test_app/pages/handler/head_url.py
index 0bb927ca5..765f2fd2d 100644
--- a/tests/projects/test_app/pages/handler/head_url.py
+++ b/tests/projects/test_app/pages/handler/head_url.py
@@ -1,9 +1,11 @@
import http.client
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
head_result = await self.head_url(self.request.host, '/handler/head', name='head')
diff --git a/tests/projects/test_app/pages/handler/json.py b/tests/projects/test_app/pages/handler/json.py
index c96045732..810dc8463 100644
--- a/tests/projects/test_app/pages/handler/json.py
+++ b/tests/projects/test_app/pages/handler/json.py
@@ -1,12 +1,15 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
def _page_handler(self) -> None:
self.text = self.get_body_argument('foo')
+ @router.post()
async def post_page(self):
return self._page_handler()
+ @router.put()
async def put_page(self):
return self._page_handler()
diff --git a/tests/projects/test_app/pages/handler/json_optional_args.py b/tests/projects/test_app/pages/handler/json_optional_args.py
index a0c154610..10f305866 100644
--- a/tests/projects/test_app/pages/handler/json_optional_args.py
+++ b/tests/projects/test_app/pages/handler/json_optional_args.py
@@ -1,12 +1,15 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
def _page_handler(self) -> None:
self.text = self.get_body_argument('foo', 'baz')
+ @router.post()
async def post_page(self):
return self._page_handler()
+ @router.put()
async def put_page(self):
return self._page_handler()
diff --git a/tests/projects/test_app/pages/http_client/custom_headers.py b/tests/projects/test_app/pages/http_client/custom_headers.py
index 75246622d..70ce62a03 100644
--- a/tests/projects/test_app/pages/http_client/custom_headers.py
+++ b/tests/projects/test_app/pages/http_client/custom_headers.py
@@ -1,7 +1,8 @@
import frontik.handler
-
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path)
self.json.put(result.data)
@@ -10,5 +11,6 @@ def modify_http_client_request(self, balanced_request):
super().modify_http_client_request(balanced_request)
balanced_request.headers['X-Foo'] = 'Bar'
+ @router.post()
async def post_page(self):
self.json.put(self.request.headers)
diff --git a/tests/projects/test_app/pages/http_client/fibonacci.py b/tests/projects/test_app/pages/http_client/fibonacci.py
index 269c0524b..14528304f 100644
--- a/tests/projects/test_app/pages/http_client/fibonacci.py
+++ b/tests/projects/test_app/pages/http_client/fibonacci.py
@@ -1,10 +1,11 @@
import asyncio
from frontik import media_types
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
n = int(self.get_argument('n'))
diff --git a/tests/projects/test_app/pages/http_client/future.py b/tests/projects/test_app/pages/http_client/future.py
index af007e81b..10df492ab 100644
--- a/tests/projects/test_app/pages/http_client/future.py
+++ b/tests/projects/test_app/pages/http_client/future.py
@@ -1,7 +1,8 @@
import frontik.handler
-
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
state = {
'second_callback_must_be_async': True,
@@ -23,6 +24,7 @@ def additional_callback(future):
request_future = self.post_url(self.request.host, self.request.path)
self.add_future(request_future, self.finish_group.add(additional_callback))
+ @router.post()
async def post_page(self):
self.json.put({
'yay': 'yay'
diff --git a/tests/projects/test_app/pages/http_client/long_page_request.py b/tests/projects/test_app/pages/http_client/long_page_request.py
index 3fa158f5b..f1fe2c6e3 100644
--- a/tests/projects/test_app/pages/http_client/long_page_request.py
+++ b/tests/projects/test_app/pages/http_client/long_page_request.py
@@ -1,9 +1,10 @@
import time
import frontik.handler
-
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path, request_timeout=0.5)
self.request_callback(result.data, result.failed)
@@ -11,6 +12,7 @@ async def get_page(self):
def request_callback(self, xml: str, error: bool) -> None:
self.json.put({'error_received': bool(error)})
+ @router.post()
async def post_page(self):
self.add_timeout(
time.time() + 2, self.finish_group.add(self.check_finished(self.timeout_callback))
diff --git a/tests/projects/test_app/pages/http_client/parse_error.py b/tests/projects/test_app/pages/http_client/parse_error.py
index c39bd12fc..826ba400f 100644
--- a/tests/projects/test_app/pages/http_client/parse_error.py
+++ b/tests/projects/test_app/pages/http_client/parse_error.py
@@ -1,7 +1,8 @@
import frontik.handler
-
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
el_result = await self.post_url(self.request.host, self.request.path + '?mode=xml')
element = el_result.data
@@ -16,6 +17,7 @@ async def get_page(self):
else:
assert False
+ @router.post()
async def post_page(self):
if self.get_argument('mode') == "xml":
self.text = '''this is broken xml'''
diff --git a/tests/projects/test_app/pages/http_client/parse_response.py b/tests/projects/test_app/pages/http_client/parse_response.py
index 818013074..247dfb842 100644
--- a/tests/projects/test_app/pages/http_client/parse_response.py
+++ b/tests/projects/test_app/pages/http_client/parse_response.py
@@ -1,9 +1,10 @@
from tornado.escape import to_unicode
-
+from frontik.handler import router
from frontik.handler import HTTPErrorWithPostprocessors, PageHandler
class Page(PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path, parse_on_error=True)
self.json.put(result.data)
@@ -14,13 +15,16 @@ async def get_page(self):
if not result.failed:
self.json.put({'delete': to_unicode(result.data)})
+ @router.post()
async def post_page(self):
self.json.put({'post': True})
raise HTTPErrorWithPostprocessors(400)
+ @router.put()
async def put_page(self):
self.json.put({'put': True})
raise HTTPErrorWithPostprocessors(400)
+ @router.delete()
async def delete_page(self):
self.text = 'deleted'
diff --git a/tests/projects/test_app/pages/http_client/post_simple.py b/tests/projects/test_app/pages/http_client/post_simple.py
index fd100462c..3d637ddc3 100644
--- a/tests/projects/test_app/pages/http_client/post_simple.py
+++ b/tests/projects/test_app/pages/http_client/post_simple.py
@@ -1,11 +1,14 @@
from frontik import handler, media_types
+from frontik.handler import router
class Page(handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path)
self.text = result.data
+ @router.post()
async def post_page(self):
self.add_header('Content-Type', media_types.TEXT_PLAIN)
self.text = 'post_url success'
diff --git a/tests/projects/test_app/pages/http_client/post_url.py b/tests/projects/test_app/pages/http_client/post_url.py
index 678cfb950..4569f0f23 100644
--- a/tests/projects/test_app/pages/http_client/post_url.py
+++ b/tests/projects/test_app/pages/http_client/post_url.py
@@ -3,7 +3,7 @@
import frontik.handler
from frontik.util import any_to_bytes, any_to_unicode
from typing import Any
-
+from frontik.handler import router
FIELDS: dict[str, Any] = {
'fielda': 'hello',
'fieldb': '',
@@ -24,11 +24,13 @@
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.post_url(self.request.host, self.request.path, data=FIELDS, files=FILES)
if not result.failed:
self.json.put(result.data)
+ @router.post()
async def post_page(self):
errors_count = 0
body_parts = self.request.body.split(b'\r\n--')
diff --git a/tests/projects/test_app/pages/http_client/proxy_code.py b/tests/projects/test_app/pages/http_client/proxy_code.py
index c7911bb42..de98f9c65 100644
--- a/tests/projects/test_app/pages/http_client/proxy_code.py
+++ b/tests/projects/test_app/pages/http_client/proxy_code.py
@@ -1,7 +1,8 @@
import frontik.handler
-
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.get_url('http://127.0.0.1:' + self.get_argument('port'), '')
self.finish(str(result.status_code))
diff --git a/tests/projects/test_app/pages/http_client/raise_error.py b/tests/projects/test_app/pages/http_client/raise_error.py
index 9263524ad..46fa9c87c 100644
--- a/tests/projects/test_app/pages/http_client/raise_error.py
+++ b/tests/projects/test_app/pages/http_client/raise_error.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
await self.post_url(self.request.host, '/a-вот')
diff --git a/tests/projects/test_app/pages/http_error.py b/tests/projects/test_app/pages/http_error.py
index f054a2a1b..b1e946acc 100644
--- a/tests/projects/test_app/pages/http_error.py
+++ b/tests/projects/test_app/pages/http_error.py
@@ -1,9 +1,10 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
code = int(self.get_argument('code', '200'))
raise HTTPError(code)
diff --git a/tests/projects/test_app/pages/include_xml.py b/tests/projects/test_app/pages/include_xml.py
index af33472ed..a1e3f8797 100644
--- a/tests/projects/test_app/pages/include_xml.py
+++ b/tests/projects/test_app/pages/include_xml.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.doc.put(self.xml_from_file('aaa.xml'))
diff --git a/tests/projects/test_app/pages/include_xml_async.py b/tests/projects/test_app/pages/include_xml_async.py
index af33472ed..a1e3f8797 100644
--- a/tests/projects/test_app/pages/include_xml_async.py
+++ b/tests/projects/test_app/pages/include_xml_async.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.doc.put(self.xml_from_file('aaa.xml'))
diff --git a/tests/projects/test_app/pages/json_page.py b/tests/projects/test_app/pages/json_page.py
index f73fec83f..36ce59e33 100644
--- a/tests/projects/test_app/pages/json_page.py
+++ b/tests/projects/test_app/pages/json_page.py
@@ -1,4 +1,5 @@
from frontik import handler, media_types
+from frontik.handler import router
from frontik.util import gather_dict
@@ -16,6 +17,7 @@ def jinja_context_provider(handler):
super().prepare()
+ @router.get()
async def get_page(self):
invalid_json = self.get_argument('invalid', 'false')
@@ -31,6 +33,7 @@ async def get_page(self):
self.set_template(self.get_argument('template', 'jinja.html'))
self.json.put(data)
+ @router.post()
async def post_page(self):
invalid_json = self.get_argument('invalid', 'false') == 'true'
diff --git a/tests/projects/test_app/pages/kafka.py b/tests/projects/test_app/pages/kafka.py
index ab5e57953..182386213 100644
--- a/tests/projects/test_app/pages/kafka.py
+++ b/tests/projects/test_app/pages/kafka.py
@@ -1,9 +1,10 @@
import asyncio
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
request_engine_builder = self.application.http_client_factory.request_engine_builder
request_engine_builder.kafka_producer.enable_for_request_id(self.request_id)
@@ -13,5 +14,6 @@ async def get_page(self):
self.json.put(*request_engine_builder.kafka_producer.disable_and_get_data())
+ @router.post()
async def post_page(self):
self.set_status(500)
diff --git a/tests/projects/test_app/pages/log.py b/tests/projects/test_app/pages/log.py
index 5d54d071a..46ffcd125 100644
--- a/tests/projects/test_app/pages/log.py
+++ b/tests/projects/test_app/pages/log.py
@@ -1,11 +1,13 @@
import logging
import frontik.handler
+from frontik.handler import router
custom_logger = logging.getLogger('custom_logger')
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.log.debug('debug')
self.log.info('info')
diff --git a/tests/projects/test_app/pages/mandatory_headers.py b/tests/projects/test_app/pages/mandatory_headers.py
index fed9a3177..c934de0e2 100644
--- a/tests/projects/test_app/pages/mandatory_headers.py
+++ b/tests/projects/test_app/pages/mandatory_headers.py
@@ -1,9 +1,10 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
if self.get_argument('test_mandatory_headers', None) is not None:
self.set_mandatory_header('TEST_HEADER', 'TEST_HEADER_VALUE')
diff --git a/tests/projects/test_app/pages/nested/nested/nested.py b/tests/projects/test_app/pages/nested/nested/nested.py
index 56857cdbb..8b5c282bb 100644
--- a/tests/projects/test_app/pages/nested/nested/nested.py
+++ b/tests/projects/test_app/pages/nested/nested/nested.py
@@ -1,6 +1,8 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.text = 'OK'
diff --git a/tests/projects/test_app/pages/postprocess.py b/tests/projects/test_app/pages/postprocess.py
index a42827223..e239a70a0 100644
--- a/tests/projects/test_app/pages/postprocess.py
+++ b/tests/projects/test_app/pages/postprocess.py
@@ -1,6 +1,6 @@
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class ContentPostprocessor:
@@ -9,6 +9,7 @@ def postprocessor(self, handler, tpl, meta_info):
class Page(PageHandler):
+ @router.get()
async def get_page(self):
if self.get_argument('raise_error', None) is not None:
self.add_postprocessor(self._pp_1)
diff --git a/tests/projects/test_app/pages/postprocess_xsl.py b/tests/projects/test_app/pages/postprocess_xsl.py
index cf382db79..1e493387b 100644
--- a/tests/projects/test_app/pages/postprocess_xsl.py
+++ b/tests/projects/test_app/pages/postprocess_xsl.py
@@ -1,6 +1,6 @@
from lxml import etree
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
@@ -8,6 +8,7 @@ class Page(PageHandler):
def extract_metainfo_pp(handler, _, meta_info):
return ','.join(meta_info)
+ @router.get()
async def get_page(self):
self.set_xsl('meta.xsl')
self.doc.put(etree.Element('ok', key=self.get_argument('meta_key', '')))
diff --git a/tests/projects/test_app/pages/proxy_code.py b/tests/projects/test_app/pages/proxy_code.py
index c4d78b517..3776829a2 100644
--- a/tests/projects/test_app/pages/proxy_code.py
+++ b/tests/projects/test_app/pages/proxy_code.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
result = await self.get_url('http://127.0.0.1:' + self.get_argument('port'), '', request_timeout=0.1)
diff --git a/tests/projects/test_app/pages/request_context.py b/tests/projects/test_app/pages/request_context.py
index a3101d8a0..7068397c9 100644
--- a/tests/projects/test_app/pages/request_context.py
+++ b/tests/projects/test_app/pages/request_context.py
@@ -3,7 +3,7 @@
from functools import partial
from frontik import request_context
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
def _callback(name, handler, *args):
@@ -11,6 +11,7 @@ def _callback(name, handler, *args):
class Page(PageHandler):
+ @router.get()
async def get_page(self):
def _waited_callback(name: str) -> Callable:
return self.finish_group.add(partial(_callback, name, self))
@@ -33,6 +34,7 @@ async def run_coroutine(self) -> None:
self.json.put({'coroutine_after_yield': request_context.get_handler_name()})
+ @router.post()
async def post_page(self):
pass
diff --git a/tests/projects/test_app/pages/sentry_error.py b/tests/projects/test_app/pages/sentry_error.py
index f3208ebcb..d0267fc3b 100644
--- a/tests/projects/test_app/pages/sentry_error.py
+++ b/tests/projects/test_app/pages/sentry_error.py
@@ -4,10 +4,11 @@
from tornado.ioloop import IOLoop
from tornado.web import HTTPError
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
ip = self.get_argument('ip', None)
extra = self.get_argument('extra_key', None)
@@ -18,9 +19,11 @@ async def get_page(self):
msg = 'My_sentry_exception'
raise Exception(msg)
+ @router.post()
async def post_page(self):
raise HTTPError(500, 'my_HTTPError')
+ @router.put()
async def put_page(self):
sentry_sdk.set_extra('extra_key', 'extra_value')
sentry_sdk.capture_message('sentry_message')
diff --git a/tests/projects/test_app/pages/simple_xml.py b/tests/projects/test_app/pages/simple_xml.py
index 5d62b9e22..631511ea4 100644
--- a/tests/projects/test_app/pages/simple_xml.py
+++ b/tests/projects/test_app/pages/simple_xml.py
@@ -2,9 +2,11 @@
import frontik.doc
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.doc.put(frontik.doc.Doc())
self.doc.put(etree.Element('element', name='Test element'))
diff --git a/tests/projects/test_app/pages/simple_xml_async.py b/tests/projects/test_app/pages/simple_xml_async.py
index 5d62b9e22..631511ea4 100644
--- a/tests/projects/test_app/pages/simple_xml_async.py
+++ b/tests/projects/test_app/pages/simple_xml_async.py
@@ -2,9 +2,11 @@
import frontik.doc
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.doc.put(frontik.doc.Doc())
self.doc.put(etree.Element('element', name='Test element'))
diff --git a/tests/projects/test_app/pages/statsd.py b/tests/projects/test_app/pages/statsd.py
index c9964075e..04a5eb700 100644
--- a/tests/projects/test_app/pages/statsd.py
+++ b/tests/projects/test_app/pages/statsd.py
@@ -1,7 +1,8 @@
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.statsd_client.count('count_metric', 10, tag1='tag1', tag2='tag2')
self.statsd_client.gauge('gauge_metric', 100, tag='tag3')
diff --git a/tests/projects/test_app/pages/test_exception_json.py b/tests/projects/test_app/pages/test_exception_json.py
index 74c4d3a29..038314c67 100644
--- a/tests/projects/test_app/pages/test_exception_json.py
+++ b/tests/projects/test_app/pages/test_exception_json.py
@@ -1,7 +1,8 @@
-from frontik.handler import HTTPErrorWithPostprocessors, PageHandler
+from frontik.handler import HTTPErrorWithPostprocessors, PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.json.put({'reason': 'bad argument'})
raise HTTPErrorWithPostprocessors(400)
diff --git a/tests/projects/test_app/pages/test_exception_text.py b/tests/projects/test_app/pages/test_exception_text.py
index fa44f093e..b0b7ece9f 100644
--- a/tests/projects/test_app/pages/test_exception_text.py
+++ b/tests/projects/test_app/pages/test_exception_text.py
@@ -1,8 +1,9 @@
-from frontik.handler import HTTPErrorWithPostprocessors, PageHandler
+from frontik.handler import HTTPErrorWithPostprocessors, PageHandler, router
from frontik.util import gather_list
class Page(PageHandler):
+ @router.get()
async def get_page(self):
async def bad_post_requests() -> None:
results = await gather_list(
diff --git a/tests/projects/test_app/pages/validate_arguments.py b/tests/projects/test_app/pages/validate_arguments.py
index 49057a478..685d88f93 100644
--- a/tests/projects/test_app/pages/validate_arguments.py
+++ b/tests/projects/test_app/pages/validate_arguments.py
@@ -2,7 +2,7 @@
from pydantic import field_validator
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.validator import BaseValidationModel, Validators
@@ -17,6 +17,7 @@ def check_string(cls, value):
class Page(PageHandler):
+ @router.get()
async def get_page(self):
is_custom_model = self.get_bool_argument('model', False)
empty_default_str = self.get_str_argument('str_arg_with_default', 'default')
@@ -42,6 +43,7 @@ async def get_page(self):
},
)
+ @router.post()
async def post_page(self):
str_body_arg = self.get_str_argument('str_argument', 'default', from_body=True)
int_body_arg = self.get_int_argument('int_argument', 0, from_body=True)
@@ -53,5 +55,6 @@ async def post_page(self):
},
)
+ @router.put()
async def put_page(self):
self.get_str_argument('str_arg', 3)
diff --git a/tests/projects/test_app/pages/write_after_finish.py b/tests/projects/test_app/pages/write_after_finish.py
index 50b2d0138..dd83852ee 100644
--- a/tests/projects/test_app/pages/write_after_finish.py
+++ b/tests/projects/test_app/pages/write_after_finish.py
@@ -1,6 +1,6 @@
import asyncio
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
class Page(PageHandler):
@@ -23,10 +23,12 @@ async def _pp(cls, handler):
await asyncio.sleep(0.1)
handler.json.put({'postprocessor_completed': True})
+ @router.get()
async def get_page(self):
await self.post_url(self.request.host, self.request.uri) # type: ignore
# test that postprocessors are scheduled only once
self.finish_with_postprocessors()
+ @router.post()
async def post_page(self):
self.json.put({'counter': self.counter_static})
diff --git a/tests/projects/test_app/pages/write_error.py b/tests/projects/test_app/pages/write_error.py
index 98eda0305..e0638d03f 100644
--- a/tests/projects/test_app/pages/write_error.py
+++ b/tests/projects/test_app/pages/write_error.py
@@ -1,7 +1,9 @@
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
msg = 'exception in handler'
raise Exception(msg)
diff --git a/tests/projects/test_app/pages/xsl/apply_error.py b/tests/projects/test_app/pages/xsl/apply_error.py
index c864b0b68..1d477ba30 100644
--- a/tests/projects/test_app/pages/xsl/apply_error.py
+++ b/tests/projects/test_app/pages/xsl/apply_error.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('apply_error.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/xsl/apply_error_async.py b/tests/projects/test_app/pages/xsl/apply_error_async.py
index c864b0b68..1d477ba30 100644
--- a/tests/projects/test_app/pages/xsl/apply_error_async.py
+++ b/tests/projects/test_app/pages/xsl/apply_error_async.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('apply_error.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/xsl/parse_error.py b/tests/projects/test_app/pages/xsl/parse_error.py
index 64515bdd1..ec8358fa4 100644
--- a/tests/projects/test_app/pages/xsl/parse_error.py
+++ b/tests/projects/test_app/pages/xsl/parse_error.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('parse_error.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/xsl/parse_error_async.py b/tests/projects/test_app/pages/xsl/parse_error_async.py
index 64515bdd1..ec8358fa4 100644
--- a/tests/projects/test_app/pages/xsl/parse_error_async.py
+++ b/tests/projects/test_app/pages/xsl/parse_error_async.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('parse_error.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/xsl/simple.py b/tests/projects/test_app/pages/xsl/simple.py
index a344bda8c..87b88eb2d 100644
--- a/tests/projects/test_app/pages/xsl/simple.py
+++ b/tests/projects/test_app/pages/xsl/simple.py
@@ -1,9 +1,10 @@
from lxml import etree
-from frontik.handler import HTTPErrorWithPostprocessors, PageHandler
+from frontik.handler import HTTPErrorWithPostprocessors, PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl(self.get_argument('template', 'simple.xsl'))
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/xsl/simple_async.py b/tests/projects/test_app/pages/xsl/simple_async.py
index a344bda8c..87b88eb2d 100644
--- a/tests/projects/test_app/pages/xsl/simple_async.py
+++ b/tests/projects/test_app/pages/xsl/simple_async.py
@@ -1,9 +1,10 @@
from lxml import etree
-from frontik.handler import HTTPErrorWithPostprocessors, PageHandler
+from frontik.handler import HTTPErrorWithPostprocessors, PageHandler, router
class Page(PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl(self.get_argument('template', 'simple.xsl'))
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/xsl/syntax_error.py b/tests/projects/test_app/pages/xsl/syntax_error.py
index 20c24ed93..631893cb0 100644
--- a/tests/projects/test_app/pages/xsl/syntax_error.py
+++ b/tests/projects/test_app/pages/xsl/syntax_error.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('syntax_error.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/projects/test_app/pages/xsl/syntax_error_async.py b/tests/projects/test_app/pages/xsl/syntax_error_async.py
index 20c24ed93..631893cb0 100644
--- a/tests/projects/test_app/pages/xsl/syntax_error_async.py
+++ b/tests/projects/test_app/pages/xsl/syntax_error_async.py
@@ -1,9 +1,11 @@
from lxml import etree
import frontik.handler
+from frontik.handler import router
class Page(frontik.handler.PageHandler):
+ @router.get()
async def get_page(self):
self.set_xsl('syntax_error.xsl')
self.doc.put(etree.Element('ok'))
diff --git a/tests/test_frontik_testing.py b/tests/test_frontik_testing.py
index 1fc200b34..cdfdba4e5 100644
--- a/tests/test_frontik_testing.py
+++ b/tests/test_frontik_testing.py
@@ -5,7 +5,7 @@
from tornado.ioloop import IOLoop
from frontik.app import FrontikApplication
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.options import options
from frontik.testing import FrontikTestBase, FrontikTestCase
from frontik.util import gather_list
@@ -14,6 +14,7 @@
class AsyncHandler(PageHandler):
+ @router.get()
async def get_page(self):
self.result = 0
service_host = self.config.serviceHost # type: ignore
@@ -29,6 +30,7 @@ async def get_page(self):
class CheckConfigHandler(PageHandler):
+ @router.get()
async def get_page(self):
self.text = self.config.config_param # type: ignore
diff --git a/tests/test_handler_returned_value_processing.py b/tests/test_handler_returned_value_processing.py
index 773c3c3fc..a08a250d1 100644
--- a/tests/test_handler_returned_value_processing.py
+++ b/tests/test_handler_returned_value_processing.py
@@ -4,7 +4,7 @@
from pydantic import BaseModel
from frontik.app import FrontikApplication
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.testing import FrontikTestBase
from tests import FRONTIK_ROOT
@@ -16,16 +16,19 @@ class _PydanticModel(BaseModel):
class ReturnPydanticModelHandler(PageHandler):
+ @router.get()
async def get_page(self) -> _PydanticModel:
return _PydanticModel(int_field=1, bool_field=True, str_field='Ну привет')
class ReturnDictHandler(PageHandler):
+ @router.get()
async def get_page(self) -> dict:
return {'is_dict': True, 'msg': 'Ну привет'}
class ReturnSelfJsonPutHandler(PageHandler):
+ @router.get()
async def get_page(self) -> dict:
self.json.put({'a': 'b'})
return self.json.put({'c': 'd'}) # type: ignore[func-returns-value]
diff --git a/tests/test_telemetry.py b/tests/test_telemetry.py
index 6c50e4aa1..43fd1a96f 100644
--- a/tests/test_telemetry.py
+++ b/tests/test_telemetry.py
@@ -14,7 +14,7 @@
from frontik import request_context
from frontik.app import FrontikApplication
-from frontik.handler import PageHandler
+from frontik.handler import PageHandler, router
from frontik.integrations.telemetry import FrontikIdGenerator, get_netloc
from frontik.options import options
from frontik.testing import FrontikTestCase
@@ -76,12 +76,14 @@ def test_get_netloc(self) -> None:
class PageA(PageHandler):
+ @router.get()
async def get_page(self):
res = await self.get_url(self.request.host, '/page_b')
self.json.put(res)
class PageB(PageHandler):
+ @router.get()
async def get_page(self):
self.json.put({})