mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
feat: include status code in proxy response
This commit is contained in:
@@ -24,6 +24,7 @@ var (
|
|||||||
type proxyResponse struct {
|
type proxyResponse struct {
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
ContentType string `json:"content_type"`
|
ContentType string `json:"content_type"`
|
||||||
|
StatusCode int `json:"status_code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -83,8 +84,9 @@ func handleProxyCall(c fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.Status(resp.StatusCode)
|
||||||
c.Response().Header.SetContentType(resp.ContentType)
|
c.Response().Header.SetContentType(resp.ContentType)
|
||||||
return c.Send([]byte(rawVal))
|
return c.SendString(resp.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
func proxy(uri *url.URL) (*proxyResponse, error) {
|
func proxy(uri *url.URL) (*proxyResponse, error) {
|
||||||
@@ -106,6 +108,7 @@ func proxy(uri *url.URL) (*proxyResponse, error) {
|
|||||||
proxyResp := &proxyResponse{
|
proxyResp := &proxyResponse{
|
||||||
Content: string(data),
|
Content: string(data),
|
||||||
ContentType: contentType,
|
ContentType: contentType,
|
||||||
|
StatusCode: resp.StatusCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
j, err := json.Marshal(proxyResp)
|
j, err := json.Marshal(proxyResp)
|
||||||
|
|||||||
Reference in New Issue
Block a user