Skip to content

Commit

Permalink
Merge codecs into main repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
googollee committed Apr 15, 2024
1 parent 16d770b commit 8411f6a
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 262 deletions.
4 changes: 1 addition & 3 deletions cacheall.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package espresso
import (
"fmt"
"net/http"

"github.com/googollee/go-espresso/codec"
)

func cacheAllError(ctx Context) error {
Expand All @@ -24,7 +22,7 @@ func cacheAllError(ctx Context) error {
}
wr.WriteHeader(code)

codec := codec.Module.Value(ctx)
codec := CodecsModule.Value(ctx)
if codec == nil {
fmt.Fprintf(wr, "%v", err)
return
Expand Down
7 changes: 3 additions & 4 deletions cacheall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"testing"

"github.com/googollee/go-espresso"
"github.com/googollee/go-espresso/codec"
"github.com/googollee/go-espresso/module"
)

Expand Down Expand Up @@ -48,7 +47,7 @@ func TestCacheAllMiddleware(t *testing.T) {
},
{
name: "MiddlewareErrorWithCodec",
providers: []module.Provider{codec.Provider},
providers: []module.Provider{espresso.ProvideCodecs},
middlewares: []espresso.HandleFunc{func(ctx espresso.Context) error {
return errors.New("error")
}},
Expand All @@ -57,7 +56,7 @@ func TestCacheAllMiddleware(t *testing.T) {
},
{
name: "MiddlewareHTTPErrorWithCodec",
providers: []module.Provider{codec.Provider},
providers: []module.Provider{espresso.ProvideCodecs},
middlewares: []espresso.HandleFunc{func(ctx espresso.Context) error {
return espresso.Error(http.StatusGatewayTimeout, errors.New("gateway timeout"))
}},
Expand All @@ -66,7 +65,7 @@ func TestCacheAllMiddleware(t *testing.T) {
},
{
name: "MiddlewarePanicWithCodec",
providers: []module.Provider{codec.Provider},
providers: []module.Provider{espresso.ProvideCodecs},
middlewares: []espresso.HandleFunc{func(ctx espresso.Context) error {
panic("panic")
}},
Expand Down
19 changes: 0 additions & 19 deletions codec/context.go

This file was deleted.

40 changes: 0 additions & 40 deletions codec/default.go

This file was deleted.

114 changes: 0 additions & 114 deletions codec/examples_test.go

This file was deleted.

78 changes: 0 additions & 78 deletions codec/module.go

This file was deleted.

Loading

0 comments on commit 8411f6a

Please sign in to comment.