framesurge / perseus

A state-driven web development framework for Rust with full support for server-side rendering and static generation.
https://framesurge.sh/perseus/en-US
MIT License
2.15k stars 89 forks source link

Connection refused on custom dflt_server on GET and POST #318

Open afidegnum opened 7 months ago

afidegnum commented 7 months ago

This issue is reporting a bug in the code of Perseus. Details of the scope will be available in issue labels. The author described their issue as follows:

I am facing a connection refused error when I tried requesting from the same server after I implemented the custom server. this is the request " reqwest::get("http://0.0.0.0:8080/.perseus/hello")" I tried the following urls as well with no success: "http://0.0.0.0:8080/hello" :/hello"

The steps to reproduce this issue are as follows:

You can clone and test directly from your end. Another question. What are best practices when submitting a form? I also faced similar issue when I tried posting a form at the engine configuration side.

A minimum reproducible example is available at https://github.com/afidegnum/custom_test_server.

Tribble internal data dHJpYmJsZS1yZXBvcnRlZCxDLWJ1ZyxBLWRlcGxveW1lbnQ=
arctic-hen7 commented 7 months ago

Have you tried requesting from localhost rather than 0.0.0.0? Also, if you're running in a Docker container that can cause these kinds of issues.

afidegnum commented 7 months ago

I tried 0.0.0.0then 127.0.0.1 and this test is done on the bare machine not on docker. I had that error on docker which prompted me to run the test locally

afidegnum commented 7 months ago

A quick question. while implementing on Server integrations, how do I pass in web::Data including custom middleware from actix to perseus, I'm trying to port in a sample authentication feature as well but I'm not able to implement directly actix's HttpRequest and HttpResponse on perseus, I noticed perseus is heavilly based on http and hyper, is there any implementation doorway?

UPDATE: this is my new implementation: https://github.com/afidegnum/custom_test_server/tree/actize

I'm not able to pass cookies and sessions from pub async fn dflt_server to various states generations, can you please guide?

arctic-hen7 commented 6 months ago

Sorry for the late reply! You should be able to access all the details of the request in the request state generation function, though anything you would put in web::Data should go in your global state instead under #[cfg(engine)]. If it can't be serialized, try putting it in a lazy_static! or similar instead.