by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:26
    codecov[bot] commented #425
  • 17:26
    FSMaxB synchronize #425
  • 09:10
    dependabot-preview[bot] labeled #440
  • 09:10
    dependabot-preview[bot] opened #440
  • 09:10

    dependabot-preview[bot] on cargo

    Update pretty_env_logger requir… (compare)

  • 00:27
    dependabot-preview[bot] edited #323
  • 00:26
    dependabot-preview[bot] edited #396
  • 00:25
    dependabot-preview[bot] edited #323
  • 00:25
    dependabot-preview[bot] edited #396
  • 00:25

    nyarly on master

    Allow giving param names to glo… Merge pull request #437 from re… (compare)

  • 00:25
    nyarly closed #437
  • 00:24
    dependabot-preview[bot] edited #396
  • 00:24
    dependabot-preview[bot] edited #323
  • 00:24
    nyarly commented #437
  • 00:23
    dependabot-preview[bot] edited #323
  • 00:23
    dependabot-preview[bot] edited #396
  • 00:23
    nyarly closed #353
  • 00:23

    nyarly on master

    Fix connection upgrade capabili… Fix and reenable websocket exam… Test accept_key and 9 more (compare)

  • 00:23
    nyarly closed #392
  • 00:23
    nyarly closed #423
Pavan Kumar Sunkara
@pksunkara
@nyarly If you are worried about breaking changes after 0.5.0-rc.0, then can you please release 0.5.0-beta.0?
@colinbankier If you are part of gotham-rs:gotham-core team on github, then you have access to publishing on crates.io
Marwan Rabbâa
@waghanza
https://gotham.rs/ is down ?
Pavan Kumar Sunkara
@pksunkara
I created an issue for the pre-release. gotham-rs/gotham#429
msrd0
@msrd0
:thumbsup: I would also love to see a pre-release
Davis Silverman
@sinistersnare
What is the recommended way of using ? in HandlerFuture functions? Result<(State, Response<Body>)> doesnt work because there is no default impl for it
I implemented IntoHandler for my Result type, but I dont think there is a similar blanket impl for IntoHandlerFuture
Davis Silverman
@sinistersnare
trying to impl it in Gotham, why doesnt into_handler_future get a State to work with?
msrd0
@msrd0
@sinistersnare It kinda gets a State, because it is only implemented for (State, T) and itself. I assume the reason for having this is so you can have a handler be a function that just returns a generic (State, T) and gotham can handle the conversion into a Box<HandlerFuture> for you.
matrixbot
@matrixbot
gitterbot was kicked by Dominic.
gitterbot was kicked by Dominic.
Davis Silverman
@sinistersnare
I cant return (State, Result<T>) because then ? wont work, as ? would return Err(...), and not return (thestate, Err(...))
Davis Silverman
@sinistersnare

I added this to Gotham, which worked:

impl<T, E> IntoHandlerFuture for ::std::result::Result<T, E>
where
    T: IntoHandlerFuture,
    E: IntoHandlerFuture {
    fn into_handler_future(self) -> Pin<Box<HandlerFuture>> {
        match self {
            Ok(hf) => hf.into_handler_future(),
            Err(hf) => hf.into_handler_future(),
        }
    }
}

However, now I need to impl IntoHandlerFuture for my Error type. That doesnt seem possible as my error doesnt have any state:

    impl IntoHandlerFuture for Error {
        fn into_handler_future(self) -> Pin<Box<HandlerFuture>> {
            // wat do?!
        }
    }
}
msrd0
@msrd0_gitlab
@pksunkara nice blog post! Gotham being the most capable one (although sometimes more elaborate than the others) matches my experience, although I never did a side-by-side comparison like you did
Judson Lester
@nyarly
At long last, I'm doing a quick review of PRs and will cut 0.5-beta presently.
Colin Bankier
@colinbankier
Thanks @nyarly - we now have a pre-release published at: https://crates.io/crates/gotham/0.5.0-rc.1
msrd0
@msrd0_gitlab
Thanks for the pre-release @colinbankier! However, I believe since gotham_middleware_diesel exposes impl Middleware, and Middleware comes from gotham, it is a breaking change for the gotham version to be updated and shouldn't happen in a patch release from 0.1.0 to 0.1.2
Denis Lisov
@tanriol
Is it a design decision that HandlerError does not have From implementations?
msrd0
@msrd0_gitlab
@tanriol my best guess is that since HandlerError implements Error and IntoHandlerError is implemented for Error + Send + 'static, the From implementation would clash with the generic one provided in std
Denis Lisov
@tanriol
Yeah, makes sense... looks like I'd need a wrapper for my take on a limited to_async...
msrd0
@msrd0_gitlab
@tanriol to_async is about to make it into the api: gotham-rs/gotham#281
Denis Lisov
@tanriol
@msrd0_gitlab Well, the main point in my case was to simplify other parts. I'll have to look whether to_async helps with that :-)
What's currently the "mainline" Gotham way of returning an error?
msrd0
@msrd0_gitlab
@tanriol Depends on what you want ... if all you want is an auto-generated 500 response, you can return (state, err.into_handler_error()) from your handler, or future::err((state, err.into_handler_error())).boxed() for async
Denis Lisov
@tanriol

Ideally I want something like

some_call_returning_result().error_status(StatusCode::BAD_REQUEST)?;

but I do understand the explicit by-value state passing is not very compatible with this. Would be mostly ok with something like

some_call_returning_result()
    .error_response(StatusCode::BAD_REQUEST, state.take())?;
msrd0
@msrd0_gitlab
well, your error_response is basically map_err(|err| (state, err.into_handler_error())) but unfortunately something rusts borrow checker doesn't like
I don't know your exact use case, but I'd probably suggest creating a wrapper that takes a callback, in which you can use ?, and then have the wrapper take care of the state and returning the (error) response
Denis Lisov
@tanriol
Yeah, and that's exactly why I have a wrapper that I currently use like this
        route.post("/api/bus/raw").to_simple(
            |(state, command): (GseState, FormBody<Cmd>)| async move {
                let mut state = state.0.lock().expect("propagating panic");
                let command: Vec<u8> =
                    hex::decode(&command.cmd).map_err(|_| ErrorCode(StatusCode::BAD_REQUEST))?;
                let reply = block_on(state.scheduler.call(command))
                    .map_err(|_| ErrorCode(StatusCode::INTERNAL_SERVER_ERROR))?;
                state.update_status();
                Ok(hex::encode(reply))
            },
        );
(the block_on may be redundant now, this was written pre-async and only slightly adapted)
Denis Lisov
@tanriol
Does it look like something worth a PR or like API bloat better kept to my project? :-)
msrd0
@msrd0_gitlab
Well, I'm not a maintainer, but I put my api bloat into my own project, in case you are interested: https://gitlab.com/msrd0/gotham-restful
Denis Lisov
@tanriol
Looks interesting, thanks for the link!
Pavan Kumar Sunkara
@pksunkara
I am working on full framework that implements all the wrappers. You can see here how easy it is to write a route handler. https://github.com/pksunkara/reign/blob/05c2738e8f1cf679331a5a83c4f2e05e837623e0/examples/router/gotham/src/main.rs#L27
Denis Lisov
@tanriol
@pksunkara Thank you, but I prefer less macros in the router :-)
Pavan Kumar Sunkara
@pksunkara
I understand. I made them macros because they intelligently fill path params
which is not possible with functions
Judson Lester
@nyarly
I wanted to call attention to #430 - I think the error types would be really useful but I worry about the API change required for middleware
Sean Pianka
@seanpianka
Hi all, is there a way to access path variables via a path extractor in a middleware? I am trying to setup a middleware which accepts or rejects a request based on a path variable matching data within a request header. I cannot figure how to access path variables in middlewares.
Pavan Kumar Sunkara
@pksunkara
@seanpianka You can't do it in gotham AFAIK
msrd0
@msrd0_gitlab
@seanpianka I do think this is possible but it might not be straight-forward. What gotham uses to determine whether or not to accept a request for a matcher is called RouteMatcher and it has access to the state. If (and I'm not sure at this part) the path extractor is run before the route matcher, you could borrow the path parameters inside your matcher and decide whether or not you like the request
With a normal middleware I highly doubt it is run late enough to support what you are trying to do
Sean Pianka
@seanpianka
Well that's a terribly inconvenient oversight
Denis Lisov
@tanriol
Does anyone know what's #423 waiting for?
Judson Lester
@nyarly
Looks like CI. Just restarted the build
Marwan Rabbâa
@waghanza
Hi /@all,
I have compared gotham and the other rust frameworks in https://github.com/the-benchmarker/web-frameworks/tree/cloudify#results
Any feedback is :heart:
technic93
@technic
Hi! What is the status of gotham 0.5?
Basically I want to play a bit with rust Futures and web development. I think that I need futures 0.3 because there is no sense in learning old 0.1 branch.
So I am thinking that for pet project 0.5 rc branch should be stable enough. What do you think folks? :)
msrd0
@msrd0_gitlab
I use the RC and I think it is stable for almoust any use case, so definitely go ahead and use it for your pet project
technic93
@technic
Cool