diff --git a/README.md b/README.md index 3a85dc4..6140489 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ -A **Golang** framework for web development that keeps your web applications and services **alive** and responsive with its fast and lightweight design. +A **Golang** framework for web development built on top of [Fasthttp](https://github.com/valyala/fasthttp) that keeps your web applications and services **alive** and responsive with its fast and lightweight design. + ## Features - Routing @@ -33,6 +34,8 @@ Initialize your project ([Learn](https://go.dev/blog/using-go-modules)). Then in go get github.com/gopulse/pulse ``` +***It's require fasthttp v1.45.0*** + ### Getting Started ```go diff --git a/constants/methods.go b/constants/methods.go deleted file mode 100644 index 084242d..0000000 --- a/constants/methods.go +++ /dev/null @@ -1,13 +0,0 @@ -package constants - -const ( - GetMethod = "GET" - PostMethod = "POST" - PutMethod = "PUT" - PatchMethod = "PATCH" - DeleteMethod = "DELETE" - HeadMethod = "HEAD" - OptionsMethod = "OPTIONS" - TraceMethod = "TRACE" - ConnectMethod = "CONNECT" -) diff --git a/context.go b/context.go index 7e5d510..86c5426 100644 --- a/context.go +++ b/context.go @@ -120,7 +120,7 @@ func (c *Context) SetCookie(cookie *Cookie) { acCookie.SetExpire(cookie.Expires) } - switch utils.ToLower(cookie.SameSite) { + switch strings.ToLower(cookie.SameSite) { case string(rune(fasthttp.CookieSameSiteStrictMode)): acCookie.SetSameSite(fasthttp.CookieSameSiteStrictMode) case string(rune(fasthttp.CookieSameSiteNoneMode)): diff --git a/route.go b/route.go index 6a3c8c6..03522d3 100644 --- a/route.go +++ b/route.go @@ -1,6 +1,8 @@ package pulse -import "github.com/gopulse/pulse/constants" +import ( + "github.com/valyala/fasthttp" +) type route struct { method string @@ -24,45 +26,45 @@ func (r *route) Name() string { // Get adds the route to the router with the GET method func (r *Router) Get(path string, handlers ...Handler) { - r.add(constants.GetMethod, path, handlers) + r.add(fasthttp.MethodGet, path, handlers) } // Post adds the route to the router with the POST method func (r *Router) Post(path string, handlers ...Handler) { - r.add(constants.PostMethod, path, handlers) + r.add(fasthttp.MethodPost, path, handlers) } // Put adds the route to the router with the PUT method func (r *Router) Put(path string, handlers ...Handler) { - r.add(constants.PutMethod, path, handlers) + r.add(fasthttp.MethodPut, path, handlers) } // Delete adds the route to the router with the DELETE method func (r *Router) Delete(path string, handlers ...Handler) { - r.add(constants.DeleteMethod, path, handlers) + r.add(fasthttp.MethodDelete, path, handlers) } // Patch adds the route to the router with the PATCH method func (r *Router) Patch(path string, handlers ...Handler) { - r.add(constants.PatchMethod, path, handlers) + r.add(fasthttp.MethodPatch, path, handlers) } // Head adds the route to the router with the HEAD method func (r *Router) Head(path string, handlers ...Handler) { - r.add(constants.HeadMethod, path, handlers) + r.add(fasthttp.MethodHead, path, handlers) } // Options adds the route to the router with the OPTIONS method func (r *Router) Options(path string, handlers ...Handler) { - r.add(constants.OptionsMethod, path, handlers) + r.add(fasthttp.MethodOptions, path, handlers) } // Connect adds the route to the router with the CONNECT method func (r *Router) Connect(path string, handlers ...Handler) { - r.add(constants.ConnectMethod, path, handlers) + r.add(fasthttp.MethodConnect, path, handlers) } // Trace adds the route to the router with the TRACE method func (r *Router) Trace(path string, handlers ...Handler) { - r.add(constants.TraceMethod, path, handlers) + r.add(fasthttp.MethodTrace, path, handlers) } diff --git a/utils/strings.go b/utils/strings.go deleted file mode 100644 index f6a5801..0000000 --- a/utils/strings.go +++ /dev/null @@ -1,7 +0,0 @@ -package utils - -import "strings" - -func ToLower(s string) string { - return strings.ToLower(s) -} diff --git a/utils/strings_test.go b/utils/strings_test.go deleted file mode 100644 index 4b70cc9..0000000 --- a/utils/strings_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package utils - -import ( - "fmt" - "testing" -) - -func TestToLower(t *testing.T) { - t.Parallel() - res := ToLower("MY/NAME/IS/:PARAM/*") - res = ToLower("1MY/NAME/IS/:PARAM/*") - res = ToLower("/MY2/NAME/IS/:PARAM/*") - res = ToLower("/MY3/NAME/IS/:PARAM/*") - res = ToLower("/MY4/NAME/IS/:PARAM/*") - - fmt.Println(res) -}