Home / Function/ parserRequestURL() — fiber Function Reference

parserRequestURL() — fiber Function Reference

Architecture documentation for the parserRequestURL() function in hooks.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  1b5fbd5a_fd0f_352f_699a_7598d1673fdc["parserRequestURL()"]
  14cfc1be_1c8f_085d_1a4e_f0de9527aaba["hooks.go"]
  1b5fbd5a_fd0f_352f_699a_7598d1673fdc -->|defined in| 14cfc1be_1c8f_085d_1a4e_f0de9527aaba
  style 1b5fbd5a_fd0f_352f_699a_7598d1673fdc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/hooks.go lines 72–118

func parserRequestURL(c *Client, req *Request) error {
	// Split URL into path and query parts using Cut (avoids allocation)
	uri, queryPart, _ := strings.Cut(req.url, "?")

	// If the URL doesn't start with http/https, prepend the baseURL.
	if !protocolCheck.MatchString(uri) {
		uri = c.baseURL + uri
		if !protocolCheck.MatchString(uri) {
			return ErrURLFormat
		}
	}

	// Set path parameters from the request and client.
	for key, val := range req.path.All() {
		uri = strings.ReplaceAll(uri, ":"+key, val)
	}
	for key, val := range c.path.All() {
		uri = strings.ReplaceAll(uri, ":"+key, val)
	}

	// Set the URI in the raw request.
	disablePathNormalizing := c.DisablePathNormalizing() || req.DisablePathNormalizing()
	req.RawRequest.SetRequestURI(uri)
	req.RawRequest.URI().DisablePathNormalizing = disablePathNormalizing
	if disablePathNormalizing {
		req.RawRequest.URI().SetPathBytes(req.RawRequest.URI().PathOriginal())
	}

	// Merge query parameters (split query from fragment using Cut).
	queryOnly, hashPart, _ := strings.Cut(queryPart, "#")
	args := fasthttp.AcquireArgs()
	defer fasthttp.ReleaseArgs(args)

	args.Parse(queryOnly)

	for key, value := range c.params.All() {
		args.AddBytesKV(key, value)
	}
	for key, value := range req.params.All() {
		args.AddBytesKV(key, value)
	}

	req.RawRequest.URI().SetQueryStringBytes(utils.CopyBytes(args.QueryString()))
	req.RawRequest.URI().SetHash(hashPart)

	return nil
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does parserRequestURL() do?
parserRequestURL() is a function in the fiber codebase, defined in client/hooks.go.
Where is parserRequestURL() defined?
parserRequestURL() is defined in client/hooks.go at line 72.

Analyze Your Own Codebase

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

Try Supermodel Free