Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
karldoenitz committed Feb 18, 2019
2 parents 6b966e2 + 359e74c commit d01b14e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@ go get github.com/karldoenitz/Tigo/...
package main

import (
"github.com/karldoenitz/Tigo/TigoWeb"
"net/http"
"github.com/karldoenitz/Tigo/TigoWeb"
"net/http"
)

// handler
type DemoHandler struct {
TigoWeb.BaseHandler
TigoWeb.BaseHandler
}

func (demoHandler *DemoHandler) Get() {
demoHandler.ResponseAsText("Hello Demo!")
demoHandler.ResponseAsText("Hello Demo!")
}

// 中间件
func Authorize(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// 此处授权认证逻辑
next.ServeHTTP(w, r)
}
return func(w http.ResponseWriter, r *http.Request) {
// 此处授权认证逻辑
next.ServeHTTP(w, r)
}
}

// 路由
var urls = []TigoWeb.Router{
{"/demo", &DemoHandler{}, []TigoWeb.Middleware{Authorize}},
{"/demo", &DemoHandler{}, []TigoWeb.Middleware{Authorize}},
}

func main() {
application := TigoWeb.Application{
IPAddress: "127.0.0.1",
Port: 8888,
UrlRouters: urls,
}
application.Run()
application := TigoWeb.Application{
IPAddress: "127.0.0.1",
Port: 8888,
UrlRouters: urls,
}
application.Run()
}
```
### 编译
Expand Down
30 changes: 15 additions & 15 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@ go get github.com/karldoenitz/Tigo/...
package main

import (
"github.com/karldoenitz/Tigo/TigoWeb"
"net/http"
"github.com/karldoenitz/Tigo/TigoWeb"
"net/http"
)

// handler
type DemoHandler struct {
TigoWeb.BaseHandler
TigoWeb.BaseHandler
}

func (demoHandler *DemoHandler) Get() {
demoHandler.ResponseAsText("Hello Demo!")
demoHandler.ResponseAsText("Hello Demo!")
}

// Middleware
func Authorize(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// 此处授权认证逻辑
next.ServeHTTP(w, r)
}
return func(w http.ResponseWriter, r *http.Request) {
// 此处授权认证逻辑
next.ServeHTTP(w, r)
}
}

// Router
var urls = []TigoWeb.Router{
{"/demo", &DemoHandler{}, []TigoWeb.Middleware{Authorize}},
{"/demo", &DemoHandler{}, []TigoWeb.Middleware{Authorize}},
}

func main() {
application := TigoWeb.Application{
IPAddress: "127.0.0.1",
Port: 8888,
UrlRouters: urls,
}
application.Run()
application := TigoWeb.Application{
IPAddress: "127.0.0.1",
Port: 8888,
UrlRouters: urls,
}
application.Run()
}
```
### Compile
Expand Down

0 comments on commit d01b14e

Please sign in to comment.