patx/mrhttp-asgi
Merge branch 'master' into loop_cleanup
Commit 8d4b426 · Mark Reed · 2024-03-19T21:14:07-04:00
Comments
No comments yet.
Diff
diff --cc src/mrhttp/internals/protocol.c
index 3feee68,1c9a498..b3bd66c
--- a/src/mrhttp/internals/protocol.c
+++ b/src/mrhttp/internals/protocol.c
@@@ -520,12 -517,9 +520,12 @@@ Protocol* Protocol_on_body(Protocol* se
return Protocol_handle_request( self, self->request, r );
}
- //? PyObject *ret = pipeline_queue(self, (PipelineRequest){true, self->request, task});
+ //? PyObject *ret = pipeline_queue(self, (PipelineRequest){true, 0, self->request, task});
}
- if ( r->mrq ) { //TODO
+ if ( r->mrq || r->mrq2 ) {
+ MrqClient *py_mrq;
+ if ( r->mrq ) py_mrq = self->app->py_mrq;
+ if ( r->mrq2) py_mrq = self->app->py_mrq2;
DBG printf("Route uses mrq\n");
int slot = 0;
// Pull slot from the first arg. Must be a number
diff --cc tst.py
index f808765,b260293..6c2cb56
--- a/tst.py
+++ b/tst.py
@@@ -1,40 -1,38 +1,41 @@@
-import traceback
+import traceback, mrjson
from mrhttp import app
- #import asyncmrq, mrpacker
+ import mrpacker
+
app.config["memcache"] = [ ("127.0.0.1", 11211) ]
+#app.static_cached("www","/path/to/www")
#@app.on('at_start')
#async def setup():
#app.c = asyncmrq.Client()
#await app.c.connect(servers=[("127.0.0.1",7100)])
- #@app.route('/')
- @app.route('/',options=['cache'])
-#@app.route('/',options=['session'])
[email protected]('/',_type="html")
++#@app.route('/',options=['cache'])
[email protected]('/')
def index(r):
- print( r.headers )
- #print( r.ip )
- return "yay"
- #d = r.mrpack
- #return d["name"]
- #x = r.form
- #return x["param2"]
+ return "hello world"
+
[email protected]('/123456789123456789')
+async def long(r):
+ return "long"
@app.route('/json')
def json(r):
- return r.json["name"]
+ return mrjson.dumps({'message': 'Hello, world!'})
- @app.route('/mrpacker')
- def mrpacker(r):
- return r.mrpack["name"]
+ @app.route('/mrp',_type="mrp")
+ def mrp(r):
+ return mrpacker.pack("hello")
[email protected]('/{}/tst')
+def firstarg(r,a):
+ return a
+
try:
- app.run(cores=4)
+ app.run(cores=1)
except Exception as e:
print("YAY",e)