Home / File/ proxy.go — fiber Source File

proxy.go — fiber Source File

Architecture documentation for proxy.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberCore Adapters 1 imports 11 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  409bdb74_0bb5_be72_7b00_0c1c6089b005["proxy.go"]
  c0b86961_3ef1_0168_52fc_98627566ed27["bytes"]
  409bdb74_0bb5_be72_7b00_0c1c6089b005 --> c0b86961_3ef1_0168_52fc_98627566ed27
  style 409bdb74_0bb5_be72_7b00_0c1c6089b005 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package proxy

import (
	"bytes"
	"net/url"
	"strings"
	"sync"
	"time"

	"github.com/gofiber/utils/v2"

	"github.com/gofiber/fiber/v3"

	"github.com/valyala/fasthttp"
)

// Balancer creates a load balancer among multiple upstream servers
func Balancer(config ...Config) fiber.Handler {
	// Set default config
	cfg := configDefault(config...)

	// Load balanced client
	lbc := &fasthttp.LBClient{}
	// Note that Servers, Timeout, WriteBufferSize, ReadBufferSize and TLSConfig
	// will not be used if the client are set.
	if cfg.Client == nil {
		// Set timeout
		lbc.Timeout = cfg.Timeout
		// Scheme must be provided, falls back to http
		for _, server := range cfg.Servers {
			if !strings.HasPrefix(server, "http") {
				server = "http://" + server
			}

			u, err := url.Parse(server)
			if err != nil {
				panic(err)
			}

			client := &fasthttp.HostClient{
				NoDefaultUserAgentHeader: true,
				DisablePathNormalizing:   true,
				Addr:                     u.Host,

				ReadBufferSize:  cfg.ReadBufferSize,
				WriteBufferSize: cfg.WriteBufferSize,

				TLSConfig: cfg.TLSConfig,

				DialDualStack: cfg.DialDualStack,
			}

			lbc.Clients = append(lbc.Clients, client)
		}
	} else {
		// Set custom client
		lbc = cfg.Client
	}

	// Return new handler
// ... (202 more lines)

Domain

Subdomains

Classes

Dependencies

  • bytes

Frequently Asked Questions

What does proxy.go do?
proxy.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Adapters subdomain.
What functions are defined in proxy.go?
proxy.go defines 11 function(s): Balancer, BalancerForward, Do, DoDeadline, DoRedirects, DoTimeout, DomainForward, Forward, WithClient, doAction, and 1 more.
What does proxy.go depend on?
proxy.go imports 1 module(s): bytes.
Where is proxy.go in the architecture?
proxy.go is located at middleware/proxy/proxy.go (domain: FiberCore, subdomain: Adapters, directory: middleware/proxy).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free