Skip to content

Commit

Permalink
feat: add default skipper function
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Feb 23, 2019
1 parent c0fc4fe commit b36df9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cod.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ type (
TraceListener func(*Context, TraceInfos)
)

// DefaultSkipper default skipper function(not skip)
func DefaultSkipper(c *Context) bool {
return c.Committed
}

// New create a cod instance
func New() *Cod {
d := NewWithoutServer()
Expand Down
9 changes: 9 additions & 0 deletions cod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import (
"github.com/vicanso/hes"
)

func TestSkipper(t *testing.T) {
c := &Context{
Committed: true,
}
if !DefaultSkipper(c) {
t.Fatalf("default skip fail")
}
}

func TestListenAndServe(t *testing.T) {
d := New()
go d.ListenAndServe("")
Expand Down

0 comments on commit b36df9b

Please sign in to comment.