summaryrefslogtreecommitdiff
path: root/api.go
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-11-27 11:45:00 +0800
committerEltrac <hi@guhub.cn>2025-11-27 11:45:00 +0800
commitc41a8f36676bca96b3a3c4af7ca6ab96f2ad9fc1 (patch)
tree143b7388a766c82a45890e37f1c256dbb0ff67f9 /api.go
parentbb58f6cd1d9cce5b12e2f9a30b1c9a6aaefdd54c (diff)
refactor: use standard Go tests
Diffstat (limited to 'api.go')
-rw-r--r--api.go50
1 files changed, 0 insertions, 50 deletions
diff --git a/api.go b/api.go
deleted file mode 100644
index e3c8ca8..0000000
--- a/api.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package growel
-
-import (
- "net/http"
-)
-
-// create API engine
-
-func New() *Engine {
- var a Engine
- a.router = NewRouter()
- return &a
-}
-
-// add routes
-
-func (api *Engine) GET(path string, h Handler) {
- api.router.Add("GET", path, h)
-}
-
-func (api *Engine) POST(path string, h Handler) {
- api.router.Add("POST", path, h)
-}
-
-func (api *Engine) PUT(path string, h Handler) {
- api.router.Add("PUT", path, h)
-}
-
-func (api *Engine) DELETE(path string, h Handler) {
- api.router.Add("DELETE", path, h)
-}
-
-// serve and start
-
-func (a *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
- handler, params := a.router.Find(req.Method, req.URL.Path)
- if handler == nil {
- http.NotFound(w, req)
- return
- }
- handler(&Context{
- W: w,
- R: req,
- Params: params,
- })
-}
-
-func (api *Engine) Start(port string) {
- http.ListenAndServe(port, api)
-}