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

redirect routes #797

Open
zoto-ff opened this issue Aug 27, 2024 · 2 comments
Open

redirect routes #797

zoto-ff opened this issue Aug 27, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request feature request

Comments

@zoto-ff
Copy link

zoto-ff commented Aug 27, 2024

What is the problem this feature would solve?

write less code

What is the feature you are proposing to solve the problem?

const app = new Elysia()
    .redirect('/', '/docs')
    
    // or
    .redirect({
        '/': '/docs',
        '/old-docs': '/docs'
    })

will be nice with serve.static (oven-sh/bun#13540)

What alternatives have you considered?

.get('/', ({ redirect }) => redirect('/docs'))
@zoto-ff zoto-ff added the enhancement New feature or request label Aug 27, 2024
@RaphaelNJ
Copy link

import { Elysia } from "elysia";

const app = new Elysia()
  .get("/", ({ set }) => (set.redirect = "/redirected"))
  .get("/redirected", () => "redirected")
  .listen(3000);

@zoto-ff
Copy link
Author

zoto-ff commented Aug 30, 2024

@RaphaelNJ

we already have

app.get('/', ({ redirect }) => redirect('/docs'))

my idea is write less code and use new serve.static option, which makes such routes faster

@SaltyAom SaltyAom self-assigned this Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

No branches or pull requests

3 participants