Skip to content

Commit

Permalink
Merge branch 'hotfix-0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
takama committed Aug 20, 2014
2 parents e12e5f4 + ed41cf6 commit 008b295
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Go Router
=========

A simple, compact and fast router package for use with Go services to process HTTP requests
A simple, compact and fast router package to process HTTP requests.
The router package is useful to prepare a RESTful API for Go services. It has JSON output, which bind automatically for relevant type of data. The router has timer feature to display duration of request handling in the header

[![Build Status](https://travis-ci.org/takama/router.png?branch=master)](https://travis-ci.org/takama/router)
[![GoDoc](https://godoc.org/github.com/takama/router?status.svg)](https://godoc.org/github.com/takama/router)
Expand Down Expand Up @@ -108,14 +109,17 @@ Content-Length: 102
func main() {
r := router.New()
r.GET("/api/v1/settings/database/:db", func(c *router.Control) {
c.UseTimer()

// Do something

data := map[string]map[string]string{
"Database settings": {
"database": c.Get(":db"),
"host": "localhost",
"port": "3306",
},
}
c.UseTimer()
c.Code(200).Body(data)
})
// Listen and serve on 0.0.0.0:8888
Expand Down
2 changes: 1 addition & 1 deletion control.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Param struct {
Value string
}

// Header used if non-zero Control.timer initialized by UserTimer() method
// Header is used to prepare a JSON header with duration triggered by UserTimer() method
type Header struct {
Took time.Duration `json:"took"`
Data interface{} `json:"data"`
Expand Down
5 changes: 4 additions & 1 deletion example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ func main() {
})

r.GET("/api/v1/settings/database/:db", func(c *router.Control) {
c.UseTimer()

// Do something

data := map[string]map[string]string{
"Database settings": {
"database": c.Get(":db"),
"host": "localhost",
"port": "3306",
},
}
c.UseTimer()
c.Code(200).Body(data)
})
// Listen and serve on 0.0.0.0:8888
Expand Down
5 changes: 4 additions & 1 deletion router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
// license that can be found in the LICENSE file.

/*
Package router 0.2.0 provides fast HTTP request router.
Package router 0.2.1 provides fast HTTP request router.
The router matches incoming requests by the request method and the path.
If a handle is registered for this path and method, the router delegates the
request to defined handler.
The router package is useful to prepare a RESTful API for Go services.
It has JSON output, which bind automatically for relevant type of data.
The router has timer feature to display duration of request handling in the header
Simplest example (serve static route):
Expand Down

0 comments on commit 008b295

Please sign in to comment.