xfy911 dc54d3822f docs(proxy): add package comments for proxy module
- Add package documentation for target_selector, utils, validate,
  cache_handler, and header_modifier files
- Include author attribution (xfy)
2026-06-03 15:28:53 +08:00

38 lines
1.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package proxy 提供反向代理的核心功能,支持请求转发、负载均衡、健康检查等特性。
//
// 包含代理工具函数,用于处理请求和响应的转换。
//
// 作者xfy
package proxy
import (
"bytes"
"rua.plus/lolly/internal/utils"
)
// b2s converts byte slice to string without allocation.
// WARNING: The returned string shares memory with the original slice.
// Do not modify the slice after calling this function.
func b2s(b []byte) string {
return utils.B2s(b)
}
// s2b converts string to byte slice without allocation.
// WARNING: The returned slice shares memory with the original string.
// Do not modify the slice contents.
func s2b(s string) []byte {
return utils.S2b(s)
}
// isInWhitelist checks if a header key is in the whitelist.
// Uses bytes.EqualFold for case-insensitive comparison without allocation.
func isInWhitelist(key []byte, whitelist map[string]bool) bool {
for wKey := range whitelist {
if bytes.EqualFold(key, s2b(wKey)) {
return true
}
}
return false
}