Home / File/ path.go — fiber Source File

path.go — fiber Source File

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

File go FiberCore Routing 1 imports 14 functions 8 classes

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// 📄 GitHub Repository: https://github.com/gofiber/fiber
// 📌 API Documentation: https://docs.gofiber.io
// ⚠️ This path parser was inspired by https://github.com/ucarion/urlpath
// 💖 Maintained and modified for Fiber by @renewerner87

package fiber

import (
	"bytes"
	"fmt"
	"regexp"
	"strconv"
	"strings"
	"sync"
	"time"
	"unicode"

	"github.com/gofiber/utils/v2"
	"github.com/google/uuid"
)

// routeParser holds the path segments and param names
type routeParser struct {
	segs          []*routeSegment // the parsed segments of the route
	params        []string        // that parameter names the parsed route
	wildCardCount int             // number of wildcard parameters, used internally to give the wildcard parameter its number
	plusCount     int             // number of plus parameters, used internally to give the plus parameter its number
}

var routerParserPool = &sync.Pool{
	New: func() any {
		return &routeParser{}
	},
}

// routeSegment holds the segment metadata
type routeSegment struct {
	// const information
	Const       string        // constant part of the route
	ParamName   string        // name of the parameter for access to it, for wildcards and plus parameters access iterators starting with 1 are added
	ComparePart string        // search part to find the end of the parameter
	Constraints []*Constraint // Constraint type if segment is a parameter, if not it will be set to noConstraint by default
	PartCount   int           // how often is the search part contained in the non-param segments? -> necessary for greedy search
	Length      int           // length of the parameter for segment, when its 0 then the length is undetermined
	// future TODO: add support for optional groups "/abc(/def)?"
	// parameter information
	IsParam    bool // Truth value that indicates whether it is a parameter or a constant part
	IsGreedy   bool // indicates whether the parameter is greedy or not, is used with wildcard and plus
	IsOptional bool // indicates whether the parameter is optional or not
	// common information
	IsLast           bool // shows if the segment is the last one for the route
	HasOptionalSlash bool // segment has the possibility of an optional slash
}

// different special routing signs
const (
	wildcardParam                byte = '*'  // indicates an optional greedy parameter
	plusParam                    byte = '+'  // indicates a required greedy parameter
	optionalParam                byte = '?'  // concludes a parameter by name and makes it optional
// ... (783 more lines)

Domain

Subdomains

Dependencies

  • bytes

Frequently Asked Questions

What does path.go do?
path.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Routing subdomain.
What functions are defined in path.go?
path.go defines 14 function(s): GetTrimmedParam, RemoveEscapeChar, RemoveEscapeCharBytes, RoutePatternMatch, addParameterMetaInfo, findGreedyParamLen, findNextNonEscapedCharPosition, findNextParamPosition, findParamLen, findParamLenForLastSegment, and 4 more.
What does path.go depend on?
path.go imports 1 module(s): bytes.
Where is path.go in the architecture?
path.go is located at path.go (domain: FiberCore, subdomain: Routing).

Analyze Your Own Codebase

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

Try Supermodel Free