mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
chore(docs): add and refine package-level comments across modules
- Added detailed package-level comments to improve documentation coverage. - Clarified parameter descriptions, return types, and functionality of exported methods across packages. - Enhanced overall code readability and API documentation consistency.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
// Package misc provides miscellaneous utility functions for the CLI Proxy API server.
|
||||
// It includes helper functions for HTTP header manipulation and other common operations
|
||||
// that don't fit into more specific packages.
|
||||
package misc
|
||||
|
||||
import (
|
||||
@@ -5,6 +8,16 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// EnsureHeader ensures that a header exists in the target header map by checking
|
||||
// multiple sources in order of priority: source headers, existing target headers,
|
||||
// and finally the default value. It only sets the header if it's not already present
|
||||
// and the value is not empty after trimming whitespace.
|
||||
//
|
||||
// Parameters:
|
||||
// - target: The target header map to modify
|
||||
// - source: The source header map to check first (can be nil)
|
||||
// - key: The header key to ensure
|
||||
// - defaultValue: The default value to use if no other source provides a value
|
||||
func EnsureHeader(target http.Header, source http.Header, key, defaultValue string) {
|
||||
if target == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user