summaryrefslogtreecommitdiff
path: root/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'api.go')
-rw-r--r--api.go35
1 files changed, 26 insertions, 9 deletions
diff --git a/api.go b/api.go
index 9cabe29..5682b99 100644
--- a/api.go
+++ b/api.go
@@ -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)
+}