Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuple for routes #313

Open
oscartbeaumont opened this issue Nov 19, 2024 · 1 comment
Open

Tuple for routes #313

oscartbeaumont opened this issue Nov 19, 2024 · 1 comment

Comments

@oscartbeaumont
Copy link
Member

I wonder if this formats better. Possible not so probs will be closed but just marking so I come back to it at some point.

t.router((
      admin_procedure().query("me", |ctx, arg: String| {
          println!("{:?}", ctx.user);
      }),
      admin_procedure().query("superSecretQuery", |ctx, arg: i32| {
          println!("{:?}", ctx.user);
      }),
      t.procedure().query("somePublicData", |ctx, arg: String| {
          println!("{:?}", ctx);
      }),
      // .openapi("/demo"),
      // library_scoped().query("demo", |library, arg: String| {
      //     // TODO
      // }),
  ))
@oscartbeaumont oscartbeaumont mentioned this issue Dec 3, 2024
89 tasks
@oscartbeaumont
Copy link
Member Author

Brendan's idea:

fn main() {
    t.router()
        .procedure(admin_procedure().query("me", |ctx, arg: String| {
            println!("{:?}", ctx.user);
        }))
        .procedure(
            admin_procedure().query("superSecretQuery", |ctx, arg: i32| {
                println!("{:?}", ctx.user);
            }),
        )
        .procedure(t.procedure().query("somePublicData", |ctx, arg: String| {
            println!("{:?}", ctx);
        }))
        .procedures((
            admin_procedure().query("me", |ctx, arg: String| {
                println!("{:?}", ctx.user);
            }),
            admin_procedure().query("superSecretQuery", |ctx, arg: i32| {
                println!("{:?}", ctx.user);
            }),
            t.procedure().query("somePublicData", |ctx, arg: String| {
                println!("{:?}", ctx);
            }),
        ));
}

This would require the procedure key being stablised in rspc_core not rspc but in practice rspc_axum/etc will rely on it's format so i'm not sure this really changes anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant