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

API route proposed changes #178

Merged
merged 5 commits into from
May 3, 2022
Merged

API route proposed changes #178

merged 5 commits into from
May 3, 2022

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Apr 25, 2022

  • Start Date: 2022-04-25
  • Status: Draft

Summary

Change the signature for API routes into a single APIContext argument, allowing you to use destructing to get the properties you want:

export async function get({ params, request }) {
  if(!request.headers.has('cookie')) {
    return new Response(null, {
      status: 301,
      headers: {
        Location: '/'
      }
    });
  }

  // ...
}

Links

@matthewp
Copy link
Contributor Author

Feedback from the call:

  • Could be helped by showing what other frameworks do here.
  • Some people prefer request as the first arg and an APIContext as the second. Want to see how people respond.

@FredKSchott
Copy link
Member

+1 LGTM

Thanks for taking the extra time to flesh this out, it's nice to see that others are also using the single-argument approach and I agree that that feels like the right path forward.

@Princesseuh
Copy link
Member

Looks good! I especially really like the APIRoute way of typing the route

@FredKSchott FredKSchott changed the title Add an RFC for the API route proposed changes API route proposed changes May 2, 2022
@matthewp
Copy link
Contributor Author

matthewp commented May 3, 2022

This was accepted!

@matthewp matthewp merged commit 0a43ad6 into main May 3, 2022
@matthewp matthewp deleted the api-sig-dynamic-routes branch May 3, 2022 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants