diff options
Diffstat (limited to 'api.go')
| -rw-r--r-- | api.go | 35 |
1 files changed, 26 insertions, 9 deletions
@@ -1,18 +1,35 @@ package growel import ( - + "net/http" ) -type growel struct { } +type Api struct { + router *Router +} + +func New() *Api { + var a Api + a.router = NewRouter() + return &a +} + +func (api *Api) Start(port string) { + http.ListenAndServe(port, api.router) +} -func (growel) New() (*growel) { - return &growel{} +func (api *Api) GET(path string, h Handler) { + api.router.Add("GET", path, h) } -func (*growel) GET() {} -func (*growel) POST() {} -func (*growel) PUT() {} -func (*growel) DELETE() {} +func (api *Api) POST(path string, h Handler) { + api.router.Add("POST", path, h) +} -func (*growel) Start() {} +func (api *Api) PUT(path string, h Handler) { + api.router.Add("PUT", path, h) +} + +func (api *Api) DELETE(path string, h Handler) { + api.router.Add("DELETE", path, h) +} |
