Home / File/ header.go — gin Source File

header.go — gin Source File

Architecture documentation for header.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go RequestBinding FormBinding 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  6ad7ab93_7c26_27c2_8db3_9109ed4b9f7a["header.go"]
  08248871_dc00_f330_15ef_4a0fbf2bafbb["http"]
  6ad7ab93_7c26_27c2_8db3_9109ed4b9f7a --> 08248871_dc00_f330_15ef_4a0fbf2bafbb
  style 6ad7ab93_7c26_27c2_8db3_9109ed4b9f7a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2022 Gin Core Team. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package binding

import (
	"net/http"
	"net/textproto"
	"reflect"
)

type headerBinding struct{}

func (headerBinding) Name() string {
	return "header"
}

func (headerBinding) Bind(req *http.Request, obj any) error {
	if err := mapHeader(obj, req.Header); err != nil {
		return err
	}

	return validate(obj)
}

func mapHeader(ptr any, h map[string][]string) error {
	return mappingByPtr(ptr, headerSource(h), "header")
}

type headerSource map[string][]string

var _ setter = headerSource(nil)

func (hs headerSource) TrySet(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (bool, error) {
	return setByForm(value, field, hs, textproto.CanonicalMIMEHeaderKey(tagValue), opt)
}

Subdomains

Functions

Dependencies

  • http

Frequently Asked Questions

What does header.go do?
header.go is a source file in the gin codebase, written in go. It belongs to the RequestBinding domain, FormBinding subdomain.
What functions are defined in header.go?
header.go defines 1 function(s): mapHeader.
What does header.go depend on?
header.go imports 1 module(s): http.
Where is header.go in the architecture?
header.go is located at binding/header.go (domain: RequestBinding, subdomain: FormBinding, directory: binding).

Analyze Your Own Codebase

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

Try Supermodel Free