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

Create abstraction layer for requests #134

Open
abemedia opened this issue May 14, 2023 · 0 comments
Open

Create abstraction layer for requests #134

abemedia opened this issue May 14, 2023 · 0 comments

Comments

@abemedia
Copy link
Owner

abemedia commented May 14, 2023

Create a don.Context interface with an implementation that calls out to fasthttp.

don.Context Methods:

  • context.Context
  • io.Reader (reads from request body)
  • io.Writer (writes to response body)
  • Body() []byte (request body)
  • Method() string
  • URL() don.URL (request URL)
  • RequestHeader() don.Header
  • ResponseHeader() don.Header
  • Query() don.Params (request URL query)
  • Path() don.Params (request path params)
  • Status(int) don.Params (sets status code)
  • Redirect(string, int)
  • Decode(any) error (decode request body, path, header & query to struct)
  • Encode(any) error (encode and write to response body)

don.Header Methods:

  • Get(string) string
  • Values(string) []string
  • Add(k,v string)
  • Set(k,v string)
  • Range(f func(k,v string))

don.Params Methods:

  • Get(string) string
  • Values(string) []string
  • Range(f func(k,v string))

Use this interface in middleware and handlers that don't use don.H. Old style handlers using the fasthttp request directly should also still be supported via an adapter.

This will allow don to also run on standard lib net/http down the line by creating a second implementation of don.Context that wraps the standard lib request & response writer.

@abemedia abemedia mentioned this issue May 14, 2023
7 tasks
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

No branches or pull requests

1 participant