Skip to content

Commit

Permalink
Add tango example (#77)
Browse files Browse the repository at this point in the history
* add tango example

* fix lint
  • Loading branch information
lunny authored and appleboy committed Sep 17, 2019
1 parent f2d3b22 commit 9fdcf0f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions example/tango.go
Original file line number Diff line number Diff line change
@@ -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"
}
25 changes: 25 additions & 0 deletions example/tango_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down

0 comments on commit 9fdcf0f

Please sign in to comment.