📝 [Proposal]: Refactor Koa-Style Req
and Res
structs into interfaces
#3347
Labels
Milestone
Req
and Res
structs into interfaces
#3347
Feature Proposal Description
This issue proposes to refactor the
Req
andRes
structs into views/interfaces onto theCtx
interface. This should improve DX when adding newCtx
methods, as we currently have to manually write new function code in bothctx.go
and eitherreq.go
orres.go
.This update would consist of:
ifacemaker
(if possible) to generateCtx
,Req
, andRes
interfaces for the sameDefaultCtx
structc.Req()
andc.Res()
to returnCtx
but type-casted to the appropriate interfaceAfter this is done,
Req
andRes
methods should then call the underlyingCtx
method, since theCtx
interface implements both theReq
andRes
interfaces.Originally posted by @grivera64 in #2894 (comment)
Alignment with Express API
This improvement shouldn't deviate from Fiber's alignment with the Express API, but rather updates the internal representation of the
Req
andRes
struct into interfaces, which is part of the Express API.HTTP RFC Standards Compliance
N/A
API Stability
Fiber's API will have improved stability, since all methods in
Ctx
will be automatically be used into the respectiveReq
andRes
interfaces. This will make it so that we don't accidentally forget to update theReq
/Res
implementations after making a change to the coreCtx
methods.Feature Examples
Checklist:
The text was updated successfully, but these errors were encountered: