Added api & route handling
Some checks failed
Build on push / prepare (push) Successful in 9s
Build on push / core (push) Successful in 19s
Build on push / query (push) Successful in 19s
Build on push / dependency (push) Successful in 17s
Build on push / application (push) Successful in 15s
Build on push / database (push) Successful in 18s
Build on push / mail (push) Successful in 19s
Build on push / translation (push) Successful in 23s
Build on push / auth (push) Successful in 16s
Build on push / api (push) Failing after 14s
Some checks failed
Build on push / prepare (push) Successful in 9s
Build on push / core (push) Successful in 19s
Build on push / query (push) Successful in 19s
Build on push / dependency (push) Successful in 17s
Build on push / application (push) Successful in 15s
Build on push / database (push) Successful in 18s
Build on push / mail (push) Successful in 19s
Build on push / translation (push) Successful in 23s
Build on push / auth (push) Successful in 16s
Build on push / api (push) Failing after 14s
This commit is contained in:
23
tests/custom/api/src/main.py
Normal file
23
tests/custom/api/src/main.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from cpl.api.web_app import WebApp
|
||||
from cpl.application import ApplicationBuilder
|
||||
from custom.api.src.service import PingService
|
||||
|
||||
|
||||
def main():
|
||||
builder = ApplicationBuilder[WebApp](WebApp)
|
||||
|
||||
builder.services.add_logging()
|
||||
builder.services.add_transient(PingService)
|
||||
|
||||
app = builder.build()
|
||||
app.with_route(path="/route1", fn=lambda r: JSONResponse("route1"), method="GET")
|
||||
app.with_routes_directory("routes")
|
||||
app.with_logging()
|
||||
|
||||
app.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
0
tests/custom/api/src/routes/__init__.py
Normal file
0
tests/custom/api/src/routes/__init__.py
Normal file
13
tests/custom/api/src/routes/ping.py
Normal file
13
tests/custom/api/src/routes/ping.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from urllib.request import Request
|
||||
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from cpl.api.router import Router
|
||||
from cpl.core.log import Logger
|
||||
from custom.api.src.service import PingService
|
||||
|
||||
|
||||
@Router.get(f"/ping")
|
||||
async def ping(r: Request, ping: PingService, logger: Logger):
|
||||
logger.info(f"Ping: {ping}")
|
||||
return JSONResponse(ping.ping(r))
|
||||
4
tests/custom/api/src/service.py
Normal file
4
tests/custom/api/src/service.py
Normal file
@@ -0,0 +1,4 @@
|
||||
class PingService:
|
||||
|
||||
def ping(self, r):
|
||||
return "pong"
|
||||
Reference in New Issue
Block a user