Skip to content

Commit

Permalink
Routeを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
hikaru7719 committed Jun 8, 2021
1 parent 123bfcc commit d11f789
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions route.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package tinyrouter

import (
"net/http"
)

type Route struct {
Method string
Path string
HandleFunc func(http.ResponseWriter, *http.Request)
}

func NewRoute(method string, path string, f func(http.ResponseWriter, *http.Request)) *Route {
return &Route{
Method: method,
Path: path,
HandleFunc: f,
}
}

func (m *Route) Match(r *http.Request) bool {
return false
}
4 changes: 3 additions & 1 deletion tinyrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ type Router interface {
}

// TinyRouter implements http.Handler interface.
type TinyRouter struct{}
type TinyRouter struct {
Routes []*Route
}

func NewRouter() *TinyRouter {
return &TinyRouter{}
Expand Down

0 comments on commit d11f789

Please sign in to comment.