Skip to content

Commit d66e8ed

Browse files
committed
WIP ASGI Implementation
1 parent 4e003f5 commit d66e8ed

File tree

15 files changed

+1641
-50
lines changed

15 files changed

+1641
-50
lines changed

Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,31 @@ keywords = ["http", "rewriting", "library"]
99
categories = ["network-programming", "web-development"]
1010
edition = "2024"
1111

12+
[features]
13+
default = []
14+
napi-support = ["dep:napi", "dep:napi-derive", "dep:napi-build", "http-handler/napi-support", "http-rewriter/napi-support"]
15+
1216
[lib]
1317
name = "python_node"
1418
crate-type = ["cdylib"]
1519

1620
[dependencies]
1721
async-trait = "0.1.88"
1822
bytes = "1.10.1"
19-
http-handler = { git = "ssh://git@github.com/platformatic/http-handler", features = ["napi-support"] }
20-
# http-handler = { path = "../http-handler", features = ["napi-support"] }
21-
# http-rewriter = { git = "ssh://git@github.com/platformatic/http-rewriter", features = ["napi-support"] }
22-
http-rewriter = { path = "../http-rewriter", features = ["napi-support"] }
23+
http-handler = { git = "ssh://git@github.com/platformatic/http-handler" }
24+
# http-handler = { path = "../http-handler" }
25+
# http-rewriter = { git = "ssh://git@github.com/platformatic/http-rewriter" }
26+
http-rewriter = { path = "../http-rewriter" }
2327
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
24-
napi = { version = "3.0.0-beta.8", default-features = false, features = ["napi4"] }
25-
napi-derive = "3.0.0-beta.8"
28+
napi = { version = "3.0.0-beta.8", default-features = false, features = ["napi4"], optional = true }
29+
napi-derive = { version = "3.0.0-beta.8", optional = true }
2630
pyo3 = { version = "0.25.1", features = ["auto-initialize", "experimental-async"] }
2731
pyo3-async-runtimes = { version = "0.25.0", features = ["tokio-runtime"] }
32+
thiserror = "2.0.12"
2833
tokio = { version = "1.45.1", features = ["full"] }
2934

3035
[build-dependencies]
31-
napi-build = "2.2.1"
36+
napi-build = { version = "2.2.1", optional = true }
3237

3338
[profile.release]
3439
lto = true

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#[cfg(feature = "napi-support")]
12
extern crate napi_build;
23

34
fn main() {
5+
#[cfg(feature = "napi-support")]
46
napi_build::setup();
57
}

main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ async def app(scope, receive, send):
99
],
1010
})
1111

12-
request = await receive()
13-
print("Received request:", request)
14-
1512
await send({
1613
'type': 'http.response.body',
1714
'body': b'Hello, world!',
1815
})
1916

17+
request = await receive()
18+
print("Received request:", request)
19+
2020
print("Starting ASGI application.")

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"scripts": {
2626
"artifacts": "napi artifacts",
2727
"build": "npm run build:debug -- --release",
28-
"build:debug": "napi build --platform",
28+
"build:debug": "napi build --platform --features napi-support",
2929
"prepublishOnly": "napi prepublish -t npm",
3030
"lint": "oxlint",
3131
"test": "node --test test/**.test.mjs",

0 commit comments

Comments
 (0)