dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Liveview + Fullstack - Upgrade to Hyper 1.x + HTTP 1.x

Open nikhiljha opened this issue 1 year ago • 6 comments

As of right now, Axum v0.7.2 is incompatible with Dioxus, because of breaking changes in hyper and http. This PR updates liveview and fullstack to be compatible with hyper 1.0 and http 1.0, and upgrades the Axum and Salvo adapters to be compatible as well.

Breaking Changes

(this is a horrible first PR, sorry 😭 -- but I needed this for my own project so I figured I may as well contribute it back)

  • Anyone using Axum will probably have some minor breakage, but judging by the changes needed for the examples the changes should be fairly simple.
  • Warp doesn't support Hyper / HTTP 1.0.0, so it can no longer be supported.

nikhiljha avatar Dec 26 '23 23:12 nikhiljha

Spent a solid few hours trying to support fully generic hyper bodies, ~~but then I realized there's no point because fullstack doesn't give you direct access to this API anyway 😭~~ so I ended up just using bytes::Bytes (which I think is closest to the way it was originally anyway). I still need to update examples slightly to match.

Edit: Nope, it needs to be generic. aaaaaaaa

nikhiljha avatar Dec 29 '23 20:12 nikhiljha

The liveview updates in this PR look good, but I would like to keep support for Warp if possible. https://github.com/DioxusLabs/dioxus/pull/1766 changes a lot of how server functions/fullstack works. It might be possible to remove the hyper dependency in that PR

ealmloff avatar Jan 03 '24 15:01 ealmloff

I'd really like to merge this but the warp issue is holding this PR back. What's the right way to proceed here? Should we split out supported frameworks as their own crates so they can float their own versions?

jkelleyrtp avatar Jan 11 '24 20:01 jkelleyrtp

I'd really like to merge this but the warp issue is holding this PR back. What's the right way to proceed here? Should we split out supported frameworks as their own crates so they can float their own versions?

We can float the versions within the crate by renaming the http and hyper packages based on the version:

[dependencies]
hyper = { version = "1.1.0", optional = true }
http = { version = "1.0.0", optional = true }
hyper-14 = { version = "0.14.25", package = "hyper", optional = true }
http-2 = { version = "0.2.9", package = "http", optional = true }

# ...


[features]
default = ["hot-reload", "default-tls"]
router = ["dioxus-router"]
hot-reload = ["serde_json", "futures-util"]
web = ["dioxus-web"]
desktop = ["dioxus-desktop"]
warp = ["dep:warp", "ssr", "hyper-14", "http-2"]
axum = ["dep:axum", "tower-http", "ssr", "hyper", "http"]
salvo = ["dep:salvo", "ssr", "hyper", "http"]
ssr = ["server_fn/ssr", "dioxus_server_macro/ssr", "tokio", "tokio-util", "dioxus-ssr", "tower", "http-body", "dioxus-router/ssr", "tokio-stream"]
default-tls = ["server_fn/default-tls"]
rustls = ["server_fn/rustls"]

ealmloff avatar Jan 11 '24 21:01 ealmloff

I'd really like to merge this but the warp issue is holding this PR back. What's the right way to proceed here? Should we split out supported frameworks as their own crates so they can float their own versions?

We can float the versions within the crate by renaming the http and hyper packages based on the version:

[dependencies]
hyper = { version = "1.1.0", optional = true }
http = { version = "1.0.0", optional = true }
hyper-14 = { version = "0.14.25", package = "hyper", optional = true }
http-2 = { version = "0.2.9", package = "http", optional = true }

# ...


[features]
default = ["hot-reload", "default-tls"]
router = ["dioxus-router"]
hot-reload = ["serde_json", "futures-util"]
web = ["dioxus-web"]
desktop = ["dioxus-desktop"]
warp = ["dep:warp", "ssr", "hyper-14", "http-2"]
axum = ["dep:axum", "tower-http", "ssr", "hyper", "http"]
salvo = ["dep:salvo", "ssr", "hyper", "http"]
ssr = ["server_fn/ssr", "dioxus_server_macro/ssr", "tokio", "tokio-util", "dioxus-ssr", "tower", "http-body", "dioxus-router/ssr", "tokio-stream"]
default-tls = ["server_fn/default-tls"]
rustls = ["server_fn/rustls"]

This seems good for now @nikhiljha if you're interested in splitting out the hyper deps!

jkelleyrtp avatar Jan 11 '24 23:01 jkelleyrtp

There's one more thing that needs to be changed if we want to support warp. https://github.com/DioxusLabs/dioxus/blob/53727b344de9af5bcd160fb99703a09ec0da2da4/packages/ssr/Cargo.toml#L19 https://github.com/DioxusLabs/dioxus/blob/53727b344de9af5bcd160fb99703a09ec0da2da4/packages/ssr/src/fs_cache.rs#L50-L60

fundon avatar Jan 19 '24 07:01 fundon