Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit

Permalink
Merge branch '1.0.3-development'
Browse files Browse the repository at this point in the history
* 1.0.3-development:
  Add Options route method
  Add new path for cover
  Add ServeHTTP
  • Loading branch information
bahlo committed Dec 12, 2014
2 parents 1adb07e + c2a83e8 commit 2de6d6e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ go:
before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- go get code.google.com/p/go.tools/cmd/cover
- go get golang.org/x/tools/cmd/cover
script:
- $HOME/gopath/bin/goveralls -repotoken AkV7JNH7cHZ18wz5uanmFNsOMZAQptsMZ
6 changes: 6 additions & 0 deletions goat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ func New() *Router {
return r
}

// ServeHTTP implements http.Handler
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
h := r.chain()
h.ServeHTTP(w, req)
}

// Run starts the server
func (r *Router) Run(address string) error {
return http.ListenAndServe(address, r.chain())
Expand Down
11 changes: 8 additions & 3 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,26 @@ func (r *Router) Get(path, title string, fn Handle) {
r.addRoute("GET", path, title, fn)
}

// Get adds a POST route
// Post adds a POST route
func (r *Router) Post(path, title string, fn Handle) {
r.addRoute("POST", path, title, fn)
}

// Get adds a DELETE route
// Delete adds a DELETE route
func (r *Router) Delete(path, title string, fn Handle) {
r.addRoute("DELETE", path, title, fn)
}

// Get adds a PUT route
// Put adds a PUT route
func (r *Router) Put(path, title string, fn Handle) {
r.addRoute("PUT", path, title, fn)
}

// Options adds a OPTIONS route
func (r *Router) Options(path, title string, fn Handle) {
r.addRoute("OPTIONS", path, title, fn)
}

// notFoundHandler handles (as you already know) the 404 error
func (r *Router) notFoundHandler(w http.ResponseWriter, req *http.Request) {
WriteError(w, 404, "404 Not Found")
Expand Down

0 comments on commit 2de6d6e

Please sign in to comment.