mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-27 03:21:09 +01:00
refactor: improve error handling and response formatting in API
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package ansi
|
||||
|
||||
import "regexp"
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var ansiRegexp = regexp.MustCompile(`\x1b\[[0-9;]*m`)
|
||||
|
||||
@@ -43,11 +45,3 @@ func WithANSI(s string, ansi string) string {
|
||||
func StripANSI(s string) string {
|
||||
return ansiRegexp.ReplaceAllString(s, "")
|
||||
}
|
||||
|
||||
var ToHTMLClass = map[string]string{
|
||||
"[91": "log-red",
|
||||
"[92": "log-green",
|
||||
"[93": "log-yellow",
|
||||
"[96": "log-cyan",
|
||||
"[97": "log-white",
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils/ansi"
|
||||
)
|
||||
|
||||
// AppendDuration appends a duration to a buffer with the following format:
|
||||
@@ -215,13 +213,6 @@ func AppendByteSize[T ~int | ~uint | ~int64 | ~uint64 | ~float64](size T, buf []
|
||||
return buf
|
||||
}
|
||||
|
||||
func DoYouMean(s string) string {
|
||||
if s == "" {
|
||||
return ""
|
||||
}
|
||||
return "Did you mean " + ansi.Info(s) + "?"
|
||||
}
|
||||
|
||||
func Pluralize(n int64) string {
|
||||
if n > 1 {
|
||||
return "s"
|
||||
|
||||
Reference in New Issue
Block a user