From b36df9b7f171014c339d3c103a3eac351f6f3fda Mon Sep 17 00:00:00 2001 From: vicanso Date: Sat, 23 Feb 2019 14:37:55 +0800 Subject: [PATCH] feat: add default skipper function --- cod.go | 5 +++++ cod_test.go | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/cod.go b/cod.go index 085b68f..f4b4ff8 100644 --- a/cod.go +++ b/cod.go @@ -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() diff --git a/cod_test.go b/cod_test.go index 1a06694..75d8824 100644 --- a/cod_test.go +++ b/cod_test.go @@ -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("")