mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-18 23:33:51 +01:00
refactor: replace custom helper with stdlib strings.*
This commit is contained in:
2
goutils
2
goutils
Submodule goutils updated: 01cd6d408c...0b0fa3a059
@@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/yusing/godoxy/internal/common"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -70,12 +69,12 @@ func cookieDomain(r *http.Request) string {
|
||||
}
|
||||
}
|
||||
|
||||
parts := strutils.SplitRune(reqHost, '.')
|
||||
parts := strings.Split(reqHost, ".")
|
||||
if len(parts) < 2 {
|
||||
return ""
|
||||
}
|
||||
parts[0] = ""
|
||||
return strutils.JoinRune(parts, '.')
|
||||
return strings.Join(parts, ".")
|
||||
}
|
||||
|
||||
func SetTokenCookie(w http.ResponseWriter, r *http.Request, name, value string, ttl time.Duration) {
|
||||
|
||||
@@ -46,8 +46,8 @@ func (c containerHelper) getMounts() *ordered.Map[string, string] {
|
||||
}
|
||||
|
||||
func (c containerHelper) parseImage() *types.ContainerImage {
|
||||
colonSep := strutils.SplitRune(c.Image, ':')
|
||||
slashSep := strutils.SplitRune(colonSep[0], '/')
|
||||
colonSep := strings.Split(c.Image, ":")
|
||||
slashSep := strings.Split(colonSep[0], "/")
|
||||
_, sha256, _ := strings.Cut(c.ImageID, ":")
|
||||
im := &types.ContainerImage{
|
||||
SHA256: sha256,
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/goccy/go-yaml"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
var ErrInvalidLabel = errors.New("invalid label")
|
||||
@@ -31,7 +30,7 @@ func ParseLabels(labels map[string]string, aliases ...string) (types.LabelMap, e
|
||||
ExpandWildcard(labels, aliases...)
|
||||
|
||||
for lbl, value := range labels {
|
||||
parts := strutils.SplitRune(lbl, '.')
|
||||
parts := strings.Split(lbl, ".")
|
||||
if parts[0] != NSProxy {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -199,7 +200,7 @@ func (mon *monitor) Detail() string {
|
||||
|
||||
// Name implements HealthMonitor.
|
||||
func (mon *monitor) Name() string {
|
||||
parts := strutils.SplitRune(mon.service, '/')
|
||||
parts := strings.Split(mon.service, "/")
|
||||
return parts[len(parts)-1]
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"strings"
|
||||
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -54,7 +53,7 @@ func (method HTTPMethod) Fulfill(req *http.Request, res *http.Response) bool {
|
||||
|
||||
// Parse implements strutils.Parser.
|
||||
func (k *HTTPHeader) Parse(v string) error {
|
||||
split := strutils.SplitRune(v, '=')
|
||||
split := strings.Split(v, "=")
|
||||
switch len(split) {
|
||||
case 1:
|
||||
split = append(split, "")
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
@@ -32,7 +33,7 @@ var defaultChunkSize = 32 * kilobyte
|
||||
//
|
||||
// Parse implements strutils.Parser.
|
||||
func (r *Retention) Parse(v string) (err error) {
|
||||
split := strutils.SplitSpace(v)
|
||||
split := strings.Fields(v)
|
||||
if len(split) != 2 {
|
||||
return fmt.Errorf("%w: %s", ErrInvalidSyntax, v)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
type StatusCodeRange struct {
|
||||
@@ -22,7 +22,7 @@ func (r *StatusCodeRange) Includes(code int) bool {
|
||||
|
||||
// Parse implements strutils.Parser.
|
||||
func (r *StatusCodeRange) Parse(v string) error {
|
||||
split := strutils.SplitRune(v, '-')
|
||||
split := strings.Split(v, "-")
|
||||
switch len(split) {
|
||||
case 1:
|
||||
start, err := strconv.Atoi(split[0])
|
||||
|
||||
@@ -3,9 +3,9 @@ package route
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
type Port struct {
|
||||
@@ -20,7 +20,7 @@ var (
|
||||
|
||||
// Parse implements strutils.Parser.
|
||||
func (p *Port) Parse(v string) (err error) {
|
||||
parts := strutils.SplitRune(v, ':')
|
||||
parts := strings.Split(v, ":")
|
||||
switch len(parts) {
|
||||
case 1:
|
||||
p.Listening = 0
|
||||
|
||||
Reference in New Issue
Block a user