Home / File/ core.go — fiber Source File

core.go — fiber Source File

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

File go FiberClient Hooks 1 imports 7 functions 5 classes

Entity Profile

Dependency Diagram

graph LR
  4d6a97ea_f5b0_e6d4_babb_935abdbbbe6c["core.go"]
  cc7104af_aece_1fe5_3985_791c7f34910c["context"]
  4d6a97ea_f5b0_e6d4_babb_935abdbbbe6c --> cc7104af_aece_1fe5_3985_791c7f34910c
  style 4d6a97ea_f5b0_e6d4_babb_935abdbbbe6c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Core pipeline scaffolds request execution for Fiber's HTTP client, including
// hook invocation, retry orchestration, and timeout management around fasthttp
// transports.
package client

import (
	"context"
	"errors"
	"net"
	"strconv"
	"strings"
	"sync"

	"github.com/valyala/fasthttp"

	"github.com/gofiber/fiber/v3"
	"github.com/gofiber/fiber/v3/addon/retry"
)

const boundary = "FiberFormBoundary"

// RequestHook is a function invoked before the request is sent.
// It receives a Client and a Request, allowing you to modify the Request or Client data.
type RequestHook func(*Client, *Request) error

// ResponseHook is a function invoked after a response is received.
// It receives a Client, Response, and Request, allowing you to modify the Response data
// or perform actions based on the response.
type ResponseHook func(*Client, *Response, *Request) error

// RetryConfig is an alias for the `retry.Config` type from the `addon/retry` package.
type RetryConfig = retry.Config

// addMissingPort appends the appropriate port number to the given address if it doesn't have one.
// If isTLS is true, it uses port 443; otherwise, it uses port 80.
func addMissingPort(addr string, isTLS bool) string { //revive:disable-line:flag-parameter
	if strings.IndexByte(addr, ':') != -1 {
		return addr
	}
	port := 80
	if isTLS {
		port = 443
	}
	return net.JoinHostPort(addr, strconv.Itoa(port))
}

// core stores middleware and plugin definitions and defines the request execution process.
type core struct {
	client *Client
	req    *Request
	ctx    context.Context //nolint:containedctx // Context is needed here.
}

// getRetryConfig returns a copy of the client's retry configuration.
func (c *core) getRetryConfig() *RetryConfig {
	c.client.mu.RLock()
	defer c.client.mu.RUnlock()

	cfg := c.client.RetryConfig()
	if cfg == nil {
// ... (245 more lines)

Domain

Subdomains

Dependencies

  • context

Frequently Asked Questions

What does core.go do?
core.go is a source file in the fiber codebase, written in go. It belongs to the FiberClient domain, Hooks subdomain.
What functions are defined in core.go?
core.go defines 7 function(s): acquireErrChan, acquireResponseChan, addMissingPort, error, newCore, releaseErrChan, releaseResponseChan.
What does core.go depend on?
core.go imports 1 module(s): context.
Where is core.go in the architecture?
core.go is located at client/core.go (domain: FiberClient, subdomain: Hooks, directory: client).

Analyze Your Own Codebase

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

Try Supermodel Free