Migrate remaining footnote-style collection access in examples, public/structure, and ext/lib smokes to [key](base); teach link-index in structure pages and use bracket calls in the cafe journal example. Co-authored-by: Cursor <cursoragent@cursor.com>
2.0 KiB
title: web proxy/invoke smoke description: Offline assemble of app.proxy and app.invoke routes (no listen). import web:ext/web/web.mq.md import plugin:lib/plugin.mq.md import sys:lib/sys.mq.md
main
p = > plugin.native_path name="web"
p
plugin.load path=
p
sys.exit code=1
proxy_tbl =
| path | upstream | stream | strip_prefix | methods | headers_from_env | timeout_ms |
|---|---|---|---|---|---|---|
| /proxy/chat | $OPENAI_BASE_URL | True | /proxy | POST | OPENAI_API_KEY=Authorization | 60000 |
invoke_tbl =
| path | method | fn | body | return |
|---|---|---|---|---|
| /api/echo | POST | demo.echo | json | json |
pg = > web.page title="proxy-invoke"
app = > web.app page=pg
app = > app.configure proxy=proxy_tbl invoke=invoke_tbl
app = > app.proxy path="/v1/stream" upstream="https://example.com/v1/chat" stream=True headers_from_env="TOKEN=X-Token"
app = > app.invoke path="/api/ping" fn="demo.ping" method="GET" body="query"
proutes = proxy_routes chat = proxy/chat up = upstream
up== "$OPENAI_BASE_URL"
print text=proxy-table-ok
print text=proxy-table-fail
stream = stream
stream
print text=proxy-stream-ok
print text=proxy-stream-fail
hdr = headers_from_env
hdr== "OPENAI_API_KEY=Authorization"
print text=proxy-env-ok
print text=proxy-env-fail
v1u== "https://example.com/v1/chat"
print text=proxy-method-ok
print text=proxy-method-fail
iroutes = invoke_routes echo = api/echo efn = fn
efn== "demo.echo"
print text=invoke-table-ok
print text=invoke-table-fail
pm== "GET"
print text=invoke-method-ok
print text=invoke-method-fail