refactor: move task, error and testing utils to separte repo; apply gofumpt

This commit is contained in:
yusing
2025-09-27 13:41:50 +08:00
parent 5043ef778f
commit 6776f20332
203 changed files with 696 additions and 2800 deletions

View File

@@ -11,8 +11,8 @@ import (
"github.com/yusing/godoxy/internal/net/gphttp/middleware"
"github.com/yusing/godoxy/internal/net/gphttp/middleware/errorpage"
"github.com/yusing/godoxy/internal/route/routes"
"github.com/yusing/godoxy/internal/task"
"github.com/yusing/godoxy/internal/types"
"github.com/yusing/goutils/task"
)
type Entrypoint struct {
@@ -56,15 +56,15 @@ func (ep *Entrypoint) SetMiddlewares(mws []map[string]any) error {
func (ep *Entrypoint) SetAccessLogger(parent task.Parent, cfg *accesslog.RequestLoggerConfig) (err error) {
if cfg == nil {
ep.accessLogger = nil
return
return err
}
ep.accessLogger, err = accesslog.NewAccessLogger(parent, cfg)
if err != nil {
return
return err
}
log.Debug().Msg("entrypoint access logger created")
return
return err
}
func (ep *Entrypoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {

View File

@@ -12,8 +12,8 @@ import (
"github.com/yusing/godoxy/internal/route"
"github.com/yusing/godoxy/internal/route/routes"
"github.com/yusing/godoxy/internal/task"
"github.com/yusing/godoxy/internal/types"
"github.com/yusing/goutils/task"
)
type noopResponseWriter struct {
@@ -24,10 +24,12 @@ type noopResponseWriter struct {
func (w *noopResponseWriter) Header() http.Header {
return http.Header{}
}
func (w *noopResponseWriter) Write(b []byte) (int, error) {
w.written = b
return len(b), nil
}
func (w *noopResponseWriter) WriteHeader(statusCode int) {
w.statusCode = statusCode
}
@@ -45,7 +47,7 @@ func (t noopTransport) RoundTrip(req *http.Request) (*http.Response, error) {
func BenchmarkEntrypointReal(b *testing.B) {
var ep Entrypoint
var req = http.Request{
req := http.Request{
Method: "GET",
URL: &url.URL{Path: "/", RawPath: "/"},
Host: "test.domain.tld",
@@ -107,7 +109,7 @@ func BenchmarkEntrypointReal(b *testing.B) {
func BenchmarkEntrypoint(b *testing.B) {
var ep Entrypoint
var req = http.Request{
req := http.Request{
Method: "GET",
URL: &url.URL{Path: "/", RawPath: "/"},
Host: "test.domain.tld",

View File

@@ -6,7 +6,7 @@ import (
"github.com/yusing/godoxy/internal/route"
"github.com/yusing/godoxy/internal/route/routes"
expect "github.com/yusing/godoxy/internal/utils/testing"
expect "github.com/yusing/goutils/testing"
)
var ep = NewEntrypoint()