27 Star 109 Fork 25

MJ PC Lab/go-http-file-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
helper.go 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
package param
import (
"../goVirtualHost"
"../util"
"crypto/tls"
"regexp"
"strings"
)
func LoadCertificate(certFile, keyFile string) (*tls.Certificate, error) {
return goVirtualHost.LoadCertificate(certFile, keyFile)
}
func EntriesToUsers(entries []string) []*user {
users := make([]*user, 0, len(entries))
for _, userEntry := range entries {
username := userEntry
password := ""
colonIndex := strings.IndexByte(userEntry, ':')
if colonIndex >= 0 {
username = userEntry[:colonIndex]
password = userEntry[colonIndex+1:]
}
users = append(users, &user{username, password})
}
return users
}
func WildcardToRegexp(wildcards []string, found bool) (*regexp.Regexp, error) {
if !found || len(wildcards) == 0 {
return nil, nil
}
normalizedWildcards := make([]string, 0, len(wildcards))
for _, wildcard := range wildcards {
if len(wildcard) == 0 {
continue
}
normalizedWildcards = append(normalizedWildcards, util.WildcardToRegexp(wildcard))
}
if len(normalizedWildcards) == 0 {
return nil, nil
}
exp := strings.Join(normalizedWildcards, "|")
return regexp.Compile(exp)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mjpclab/go-http-file-server.git
git@gitee.com:mjpclab/go-http-file-server.git
mjpclab
go-http-file-server
go-http-file-server
v1.6.0

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385