DomainForward performs an http request based on the given domain and populates the given http response. This method will return a fiber.Handler
(hostname, addr string, clients ...*fasthttp.Client)
| 240 | // DomainForward performs an http request based on the given domain and populates the given http response. |
| 241 | // This method will return a fiber.Handler |
| 242 | func DomainForward(hostname, addr string, clients ...*fasthttp.Client) fiber.Handler { |
| 243 | return func(c fiber.Ctx) error { |
| 244 | host := utils.UnsafeString(c.Request().Host()) |
| 245 | if host == hostname { |
| 246 | c.Request().Header.Set("X-Real-IP", c.IP()) |
| 247 | return Do(c, addr+c.OriginalURL(), clients...) |
| 248 | } |
| 249 | return nil |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | type roundrobin struct { |
| 254 | pool []string |