diff --git a/example/tango.go b/example/tango.go new file mode 100644 index 0000000..1d09493 --- /dev/null +++ b/example/tango.go @@ -0,0 +1,15 @@ +package example + +import ( + "gitea.com/lunny/tango" +) + +// HelloAction for tango router +type HelloAction struct { + tango.Ctx +} + +// Get will be executed when GET requests +func (c *HelloAction) Get() string { + return "Hello, World" +} diff --git a/example/tango_test.go b/example/tango_test.go new file mode 100644 index 0000000..dddbebd --- /dev/null +++ b/example/tango_test.go @@ -0,0 +1,25 @@ +package example + +import ( + "fmt" + "net/http" + "testing" + + "gitea.com/lunny/tango" + "github.com/appleboy/gofight/v2" + "github.com/stretchr/testify/assert" +) + +func TestTangoHelloWorld(t *testing.T) { + tan := tango.New(tango.Return()) + tan.Get("/", new(HelloAction)) + + r := gofight.New() + r.GET("/"). + SetDebug(true). + Run(tan, func(rp gofight.HTTPResponse, rq gofight.HTTPRequest) { + fmt.Println(rp.Code) + assert.Equal(t, "Hello, World", rp.Body.String()) + assert.Equal(t, http.StatusOK, rp.Code) + }) +} diff --git a/go.mod b/go.mod index 79afc0d..c8f2ca0 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/appleboy/gofight/v2 go 1.12 require ( + gitea.com/lunny/tango v0.6.1 github.com/astaxie/beego v1.11.1 github.com/gin-gonic/gin v1.4.0 github.com/gorilla/context v1.1.1 // indirect diff --git a/go.sum b/go.sum index 0a9c73e..25b34e5 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,7 @@ +gitea.com/lunny/log v0.0.0-20190322053110-01b5df579c4e h1:r1en/D7xJmcY24VkHkjkcJFa+7ZWubVWPBrvsHkmHxk= +gitea.com/lunny/log v0.0.0-20190322053110-01b5df579c4e/go.mod h1:uJEsN4LQpeGYRCjuPXPZBClU7N5pWzGuyF4uqLpE/e0= +gitea.com/lunny/tango v0.6.1 h1:/Fa0TZ5BY6gjWAgo0LzA0tdY8Az/fG6/oTTbFkpmxt0= +gitea.com/lunny/tango v0.6.1/go.mod h1:ebPnYxaYz9qzByTh3A7604q3tcj0QtATtdwvsAafswU= github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/astaxie/beego v1.11.1 h1:6DESefxW5oMcRLFRKi53/6exzup/IR6N4EzzS1n6CnQ= github.com/astaxie/beego v1.11.1/go.mod h1:i69hVzgauOPSw5qeyF4GVZhn7Od0yG5bbCGzmhbWxgQ=