Introduce defaults again
This commit is contained in:
+14
-10
@@ -313,13 +313,15 @@ def insert_route(app):
|
|||||||
try:
|
try:
|
||||||
index = int(content["index"])
|
index = int(content["index"])
|
||||||
assert index >= 0
|
assert index >= 0
|
||||||
route = KapowRoute(method=content["method"],
|
method = content.get("method", "GET")
|
||||||
|
entrypoint = content.get("entrypoint", "/bin/sh -c")
|
||||||
|
command = content.get("command", "")
|
||||||
|
route = KapowRoute(method=method,
|
||||||
path=content["url_pattern"],
|
path=content["url_pattern"],
|
||||||
id="ROUTE_" + str(uuid4()).replace('-', '_'),
|
id="ROUTE_" + str(uuid4()).replace('-', '_'),
|
||||||
entrypoint=content["entrypoint"],
|
entrypoint=entrypoint,
|
||||||
command=content["command"],
|
command=command,
|
||||||
handler=handle_route(content["entrypoint"],
|
handler=handle_route(entrypoint, command))
|
||||||
content["command"]))
|
|
||||||
app.change_routes((app["user_routes"][:index]
|
app.change_routes((app["user_routes"][:index]
|
||||||
+ [route]
|
+ [route]
|
||||||
+ app["user_routes"][index:]))
|
+ app["user_routes"][index:]))
|
||||||
@@ -345,13 +347,15 @@ def append_route(app):
|
|||||||
return web.Response(status=400, reason="Malformed JSON")
|
return web.Response(status=400, reason="Malformed JSON")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
route = KapowRoute(method=content["method"],
|
method = content.get("method", "GET")
|
||||||
|
entrypoint = content.get("entrypoint", "/bin/sh -c")
|
||||||
|
command = content.get("command", "")
|
||||||
|
route = KapowRoute(method=method,
|
||||||
path=content["url_pattern"],
|
path=content["url_pattern"],
|
||||||
id="ROUTE_" + str(uuid4()).replace('-', '_'),
|
id="ROUTE_" + str(uuid4()).replace('-', '_'),
|
||||||
entrypoint=content["entrypoint"],
|
entrypoint=entrypoint,
|
||||||
command=content["command"],
|
command=command,
|
||||||
handler=handle_route(content["entrypoint"],
|
handler=handle_route(entrypoint, command))
|
||||||
content["command"]))
|
|
||||||
app.change_routes(app["user_routes"] + [route])
|
app.change_routes(app["user_routes"] + [route])
|
||||||
except (InvalidRouteError, KeyError) as exc:
|
except (InvalidRouteError, KeyError) as exc:
|
||||||
return web.Response(status=422, reason="Invalid Route")
|
return web.Response(status=422, reason="Invalid Route")
|
||||||
|
|||||||
Reference in New Issue
Block a user