Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
forked from jeffotoni/quick

It is a route manager 100% using net/http, it is being born and is under development, it is intended to be fast and with high performance.

License

Notifications You must be signed in to change notification settings

jniltinho/quick

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo do Quick

GoDoc Github Release CircleCI Go Report License CircleCI Coveralls

Quick - a lightweight router for go Quick Logo

🚀 Quick is a flexible and extensible route manager for the Go language. Its goal is to be fast and high-performance, as well as being 100% compatible with net/http. Quick is a project in constant development and is open for collaboration, everyone is welcome to contribute. 😍

💡 If you’re new to coding, Quick is a great opportunity to start learning how to work with Go. With its ease of use and features, you can create custom routes and expand your knowledge of the language.

👍 I hope you can participate and enjoy Enjoy! 😍

🔍 The repository of examples of the Framework Quick Run Examples.

🎛️| Features

Features Has Status Completion
🛣️ Route Manager yes 🟢 100%
📁 Server Files Static yes 🟢 100%
🚪 Route Group yes 🟢 100%
🌐 Middlewares yes 🟢 100%
🚀 HTTP/2 support yes 🟢 100%
🧬 Data binding for JSON, XML and form payload yes 🟢 100%
🔍 Regex support yes 🟢 100%
🌐 Site yes 🟢 90%
📚 Docs yes 🟡 40%

🗺️| Development Rodmap

Task Progress
Develop MaxBodySize method Post 100%
Develop MaxBodySize method Put 100%
Develop Config in New(Config{}) not required 100%
Create print function to not use fmt too much 100%
Creation of own function for Concat String 100%
Creation of benchmarking between the. Stdout and fmt.Println 100%
Develop Routes GET method 100%
Develop Routes GET method by accepting Query String 100%
Develop Routes GET method accepting Parameters 100%
Develop Routes GET method accepting Query String and Parameters 100%
Develop Routes GET method accepting regular expression 100. %
Develop Routes Method POST 100%
Develop Routes POST method accepting JSON 100%
Develop for METHOD POST the parse JSON 100%
Develop for the POST METHOD functions to access byte or string from Parse 100%
Develop for PUT METHOD 100%
Develop for the PUT METHOD the JSON parse 100%
Develop for the PUT METHOD the JSON parse 100%
Develop for METHOD PUT functions to access byte or string from the Parse 100%
Develop for DELETE METHOD 100%
Develop method for ListenAndServe 100%
Develop ServeHTTP support 100%
Develop middleware support 100%
Develop support for middleware compress 100%
Develop support for middleware cors 100%
Develop logger middleware support 100%
Develop support for maxbody middlewares 100%
Develop middleware support msgid 100%
Develop middleware support msguuid 100%
Develop support Cors 100. %
Develop Cient Get 100. %
Develop Cient Post support 100. %
Develop Cient Put support 100. %
Develop Cient support Delete 100. %

🚧| Rodmap in progress

Task Progress
Develop and relate to Listen the Config 42%
Develops support for Group Routes - Group Get and Post 70%
Develop method to Facilitate ResponseWriter handling 80%
Develop method to Facilitate the handling of the Request 80%
Develop Standard of Unit Testing 90%

🚀| Rodmap for development

Task Progress
Documentação Tests Examples PKG Go 45.%
Cobertura de Testes go test -cover 74.6%
Cobertura de recursos Regex, mas possibilidades 0.%
Desenvolver para o MÉTODO OPTIONS 0.%
Desenvolver para o MÉTODO CONNECT Veja mais 0.%
Desenvolver método para ListenAndServeTLS (http2) 0.%
Desenvolve suporte Static Files 0.%
Criar um CLI (Command Line Interface) Quick. 0.%
WebSocket Support 0.%
Rate Limiter Support 0.%
Template Engines 0.%
Documentation Tests Examples PKG Go 45. %
Test coverage go test -cover 75.5%
Coverage of Regex resources, but possibilities 0.%
Develop for METHOD OPTIONS 0.%
Develop for CONNECT METHOD See more 0.%
Develop method for ListenAndServeTLS (http2) 0.%
Develops Static Files support 0.%
Create a CLI (Command Line Interface) Quick. 0.%

📊| Cover Testing Roadmap

Archive Coverage Status
Ctx 84.1% 🟡
Group 100.0% 🟢
Http Status 7.8% 🔴
Client 83.3% 🟢
Mock 100.0% 🟢
Concat 100.0% 🟢
Log 0.0% 🔴
Print 66.7% 🟡
Qos 0.0% 🔴
Rand 0.0% 🔴
Compressa 71,4% 🟡
Cors 76.0% 🟡
Logger 100.0% 🟢
Maxbody 100.0% 🟢
Msgid 100.0% 🟢
Msguuid 86.4% 🟢
Quick 79.5% 🟡
QuickTest 100.0% 🟢

Fast quick example

package main

import "github.com/jeffotoni/quick"

func main() {
    q := quick.New()

    q.Get("/v1/user", func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")
        return c.Status(200).SendString("Quick in action ❤️!")
    })

    q.Listen("0.0.0.0:8080")
}
$ curl -i -XGET -H "Content-Type:application/json" \
'localhost:8080/v1/user'
HTTP/1.1 200 OK
Content-Type: application/json
Date: Wed, 22 Feb 2023 07:45:36 GMT
Content-Length: 23

Quick in action ❤️!

Quick Get Params

package main

import "github.com/jeffotoni/quick"

func main() {
    q := quick.New()

    q.Get("/v1/customer/:param1/:param2", func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")

        type my struct {
            Msg string `json:"msg"`
            Key string `json:"key"`
            Val string `json:"val"`
        }

        return c.Status(200).JSON(&my{
            Msg: "Quick ❤️",
            Key: c.Param("param1"),
            Val: c.Param("param2"),
        })
    })

    q.Listen("0.0.0.0:8080")
}
$ curl -i -XGET -H "Content-Type:application/json" \
'localhost:8080/v1/customer/val1/val2'
HTTP/1.1 200 OK
Content-Type: application/json
Date: Wed, 22 Feb 2023 07:45:36 GMT
Content-Length: 23

{"msg":"Quick ❤️","key":"val1","val":"val2"}

Quick Post Body json

package main

import "github.com/jeffotoni/quick"

type My struct {
    Name string `json:"name"`
    Year int    `json:"year"`
}

func main() {
    q := quick.New()
    q.Post("/v1/user", func(c *quick.Ctx) error {
        var my My
        err := c.BodyParser(&my)
        if err != nil {
            return c.Status(400).SendString(err.Error())
        }

        return c.Status(200).String(c.BodyString())
        // ou 
        // c.Status(200).JSON(&my)
    })

    q.Listen("0.0.0.0:8080")
}
$ curl -i -XPOST -H "Content-Type:application/json" \
'localhost:8080/v1/user' \
-d '{"name":"jeffotoni", "year":1990}'
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2023 08:10:06 GMT
Content-Length: 32
Content-Type: text/plain; charset=utf-8

{"name":"jeffotoni","year":1990}

📚| More Examples

This directory contains practical examples of the Quick Framework, a fast and lightweight web framework developed in Go. The examples are organized in separate folders, each containing a complete example of using the framework in a simple web application. If you have some interesting example of using the Quick Framework, feel free to send a pull request with your contribution. The Quick Framework example repository can be found at here.

Quick Post Bind json

package main

import "github.com/jeffotoni/quick"

type My struct {
    Name string `json:"name"`
    Year int    `json:"year"`
}

func main() {
    q := quick.New()
    q.Post("/v2/user", func(c *quick.Ctx) error {
        var my My
        err := c.Bind(&my)
        if err != nil {
            return c.Status(400).SendString(err.Error())
        }
        return c.Status(200).JSON(&my)
    })

    q.Listen("0.0.0.0:8080")
}
$ curl -i -XPOST -H "Content-Type:application/json" \
'localhost:8080/v2/user' \
-d '{"name":"Marcos", "year":1990}'
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2023 08:10:06 GMT
Content-Length: 32
Content-Type: text/plain; charset=utf-8

{"name":"Marcos","year":1990}

Cors

package main

import (
    "github.com/jeffotoni/quick"
    "github.com/jeffotoni/quick/middleware/cors"
)

func main() {
    q := quick.New()
    q.Use(cors.New())

    q.Get("/v1/user", func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")
        return c.Status(200).SendString("Quick in action com Cors❤️!")
    })

    q.Listen("0.0.0.0:8080")
}

quick.New(quick.Config{})

package main

import "github.com/jeffotoni/quick"

func main() {
    q := quick.New(quick.Config{
        MaxBodySize: 5 * 1024 * 1024,
    })

    q.Get("/v1/user", func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")
        return c.Status(200).SendString("Quick in action com Cors❤️!")
    })

    q.Listen("0.0.0.0:8080")
}

quick.Group()

package main

import "github.com/jeffotoni/quick"

func main() {
    q := quick.New(quick.Config{
        MaxBodySize: 5 * 1024 * 1024,
    })

    v1 := q.Group("/v1")
    v1.Get("/user", func(c *quick.Ctx) error {
        return c.Status(200).SendString("[GET] [GROUP] /v1/user ok!!!")
    })
    v1.Post("/user", func(c *quick.Ctx) error {
        return c.Status(200).SendString("[POST] [GROUP] /v1/user ok!!!")
    })

    v2 := q.Group("/v2")
    v2.Get("/user", func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")
        return c.Status(200).SendString("Quick in action com [GET] /v2/user ❤️!")
    })

    v2.Post("/user", func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")
        return c.Status(200).SendString("Quick in action com [POST] /v2/user ❤️!")
    })

    q.Listen("0.0.0.0:8080")
}

Quick Tests

package main

import (
    "io"
    "strings"
    "testing"

    "github.com/jeffotoni/quick"
)

func TestQuickExample(t *testing.T) {

    // Here is a handler function Mock
    testSuccessMockHandler := func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")
        b, _ := io.ReadAll(c.Request.Body)
        resp := `"data":` + string(b)
        return c.Byte([]byte(resp))
    }

    q := quick.New()
    // Here you can create all routes that you want to test
    q.Post("/v1/user", testSuccessMockHandler)
    q.Post("/v1/user/:p1", testSuccessMockHandler)

    wantOutData := `"data":{"name":"jeff", "age":35}`
    reqBody := []byte(`{"name":"jeff", "age":35}`)
    reqHeaders := map[string]string{"Content-Type": "application/json"}

    data, err := q.QuickTest("POST", "/v1/user", reqHeaders, reqBody)
    if err != nil {
        t.Errorf("error: %v", err)
        return
    }

    s := strings.TrimSpace(data.BodyStr())
    if s != wantOutData {
        t.Errorf("was suppose to return %s and %s come", wantOutData, s)
        return
    }

    t.Logf("\nOutputBodyString -> %v", data.BodyStr())
    t.Logf("\nStatusCode -> %d", data.StatusCode())
    t.Logf("\nOutputBody -> %v", string(data.Body())) // I have converted in this example to string but comes []byte as default
    t.Logf("\nResponse -> %v", data.Response())
}

quick.regex

package main

import (
    "github.com/jeffotoni/quick"
    "github.com/jeffotoni/quick/middleware/msgid"
)

func main() {
    q := quick.New()

    q.Use(msgid.New())

    q.Get("/v1/user/{id:[0-9]+}", func(c *quick.Ctx) error {
        c.Set("Content-Type", "application/json")
        return c.Status(200).String("Quick ação total!!!")
    })

    q.Listen("0.0.0.0:8080")
}

🤝| Contributions

We already have several examples, and we can already test and play 😁. Of course, we are at the beginning, still has much to do. Feel free to do PR (at risk of winning a Go t-shirt ❤️ and of course recognition as a professional Go 😍 in the labor market).

🚀 Quick Project Supporters 🙏

The Quick Project aims to develop and provide quality software for the developer community. 💻 To continue improving our tools, we rely on the support of our sponsors in Patreon. 🤝

We thank all our supporters! 🙌 If you also believe in our work and want to contribute to the advancement of the development community, consider supporting Project Quick on our Patreon here

Together we can continue to build amazing tools! 🚀

Avatar User Donation
@jeffotoni x 10
@Crow3442 x 5
@Guilherme-De-Marchi x 5
@jaquelineabreu x 1

About

It is a route manager 100% using net/http, it is being born and is under development, it is intended to be fast and with high performance.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.4%
  • Other 1.6%