Skip to content

📝 [Proposal]: Help fasthttp convert to other #3311

@JIeJaitt

Description

@JIeJaitt

Feature Proposal Description

I am using go-pay is to realize the business of the payment function, found that go-pay only support to receive http.Request, I have to manually do the conversion again, most of the libraries may only implement the http.Request, maybe we can support a way to facilitate the user more simple to switch.

Feature Examples

body := c.Body() 

		httpReq := &http.Request{
			Method: string(c.Method()),
			URL:    &url.URL{Path: c.Path()},
			Body:   io.NopCloser(bytes.NewReader(body)),
			Header: make(http.Header),
		}

		// Copy headers
		c.Request().Header.VisitAll(func(key, value []byte) {
			httpReq.Header.Set(string(key), string(value))
		})

		logger.Z().Info("copy headers success")

		notifyReq, err := wechat.V3ParseNotify(httpReq)
		if err != nil {
			logger.Z().Error("Failed to parse callback notification",
				zap.String(common.X_REQUEST_ID, requestId),
				zap.Error(err))
			return c.Status(400).JSON(fiber.Map{
				"code":    "FAIL",
				"message": "失败",
			})
		}

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have searched for existing issues that describe my proposal before opening this one.
  • I understand that a proposal that does not meet these guidelines may be closed without explanation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions