⚡ Rux is an simple and fast web framework. support middleware, compatible http.Handler interface. 简单且快速的 Go web 框架,支持中间件,兼容 http.Handler 接口

Overview

Rux

GitHub go.mod Go version Actions Status GitHub tag (latest SemVer) GoDoc Build Status Coverage Status Go Report Card

Simple and fast web framework for build golang HTTP applications.

NOTICE: v1.3.x is not fully compatible with v1.2.x version

  • Fast route match, support route group
  • Support route path params and named routing
  • Support cache recently accessed dynamic routes
  • Support route middleware, group middleware, global middleware
  • Support generic http.Handler interface middleware
  • Support static file access handle
  • Support add handlers for handle NotFound and NotAllowed

中文说明

中文说明请看 README.zh-CN

GoDoc

Install

go get github.com/gookit/rux

Quick start

package main

import (
	"github.com/gookit/rux"
)

func main() {
	r := rux.New()
	
	// Add Routes:
	r.GET("/", func(c *rux.Context) {
		c.Text(200, "hello")
	})
	r.GET("/hello/{name}", func(c *rux.Context) {
		c.Text(200, "hello " + c.Param("name"))
	})
	r.POST("/post", func(c *rux.Context) {
		c.Text(200, "hello")
	})
	// add multi method support for an route path
	r.Add("/post[/{id}]", func(c *rux.Context) {
		if c.Param("id") == "" {
			// do create post
			c.Text(200, "created")
			return
		}

		id := c.Params.Int("id")
		// do update post
		c.Text(200, "updated " + fmt.Sprint(id))
	}, rux.POST, rux.PUT)

	// Start server
	r.Listen(":8080")
	// can also
	// http.ListenAndServe(":8080", r)
}

Route Group

r.Group("/articles", func() {
    r.GET("", func(c *rux.Context) {
        c.Text(200, "view list")
    })
    r.POST("", func(c *rux.Context) {
        c.Text(200, "create ok")
    })
    r.GET(`/{id:\d+}`, func(c *rux.Context) {
        c.Text(200, "view detail, id: " + c.Param("id"))
    })
})

With Path Params

You can add the path params like: {id} Or {id:\d+}

// can access by: "/blog/123"
r.GET(`/blog/{id:\d+}`, func(c *rux.Context) {
    c.Text(200, "view detail, id: " + c.Param("id"))
})

optional params, like /about[.html] or /posts[/{id}]:

// can access by: "/blog/my-article" "/blog/my-article.html"
r.GET(`/blog/{title:\w+}[.html]`, func(c *rux.Context) {
    c.Text(200, "view detail, id: " + c.Param("id"))
})

r.Add("/posts[/{id}]", func(c *rux.Context) {
    if c.Param("id") == "" {
        // do create post
        c.Text(200, "created")
        return
    }

    id := c.Params.Int("id")
    // do update post
    c.Text(200, "updated " + fmt.Sprint(id))
}, rux.POST, rux.PUT)

Use Middleware

rux support use middleware, allow:

  • global middleware
  • group middleware
  • route middleware

Call priority: global middleware -> group middleware -> route middleware

Examples:

package main

import (
	"fmt"

	"github.com/gookit/rux"
)

func main() {
	r := rux.New()
	
	// add global middleware
	r.Use(func(c *rux.Context) {
	    // do something ...
	})
	
	// add middleware for the route
	route := r.GET("/middle", func(c *rux.Context) { // main handler
		c.WriteString("-O-")
	}, func(c *rux.Context) { // middle 1
        c.WriteString("a")
        c.Next() // Notice: call Next()
        c.WriteString("A")
        // if call Abort(), will abort at the end of this middleware run
        // c.Abort() 
    })
	
	// add more by Use()
	route.Use(func(c *rux.Context) { // middle 2
		c.WriteString("b")
		c.Next()
		c.WriteString("B")
	})

	// now, access the URI /middle
	// will output: ab-O-BA
}
  • Call sequence: middle 1 -> middle 2 -> main handler -> middle 2 -> middle 1
  • Flow chart:
        +-----------------------------+
        | middle 1                    |
        |  +----------------------+   |
        |  | middle 2             |   |
 start  |  |  +----------------+  |   | end
------->|  |  |  main handler  |  |   |--->----
        |  |  |________________|  |   |    
        |  |______________________|   |  
        |_____________________________|

more please see middleware_test.go middleware tests

Use http.Handler

rux is support generic http.Handler interface middleware

You can use rux.WrapHTTPHandler() convert http.Handler as rux.HandlerFunc

package main

import (
	"net/http"
	
	"github.com/gookit/rux"
	// here we use gorilla/handlers, it provides some generic handlers.
	"github.com/gorilla/handlers"
)

func main() {
	r := rux.New()
	
	// create a simple generic http.Handler
	h0 := http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
		w.Header().Set("new-key", "val")
	})
	
	r.Use(rux.WrapHTTPHandler(h0), rux.WrapHTTPHandler(handlers.ProxyHeaders()))
	
	r.GET("/", func(c *rux.Context) {
		c.Text(200, "hello")
	})
	// add routes ...
	
    // Wrap our server with our gzip handler to gzip compress all responses.
    http.ListenAndServe(":8000", handlers.CompressHandler(r))
}

More Usage

Static Assets

package main

import (	
	"github.com/gookit/rux"
)

func main() {
	r := rux.New()

	// one file
	r.StaticFile("/site.js", "testdata/site.js")

	// allow any files in the directory.
	r.StaticDir("/static", "testdata")

	// file type limit in the directory
	r.StaticFiles("/assets", "testdata", "css|js")
}

Name Route

In rux, you can add a named route, and you can get the corresponding route instance(rux.Route) from the router according to the name.

Examples:

	r := rux.New()
	
	// Method 1
	myRoute := rux.NewNamedRoute("name1", "/path4/some/{id}", emptyHandler, "GET")
	r.AddRoute(myRoute)

	// Method 2
	rux.AddNamed("name2", "/", func(c *rux.Context) {
		c.Text(200, "hello")
	})

	// Method 3
	r.GET("/hi", func(c *rux.Context) {
		c.Text(200, "hello")
	}).NamedTo("name3", r)
	
	// get route by name
	myRoute = r.GetRoute("name1")

Redirect

redirect to other page

r.GET("/", func(c *rux.Context) {
    c.AbortThen().Redirect("/login", 302)
})

// Or
r.GET("/", func(c *rux.Context) {
    c.Redirect("/login", 302)
    c.Abort()
})

r.GET("/", func(c *rux.Context) {
    c.Back()
    c.Abort()
})

Cookies

you can quick operate cookies by FastSetCookie() DelCookie()

Note: You must set or delete cookies before writing BODY content

r.GET("/setcookie", func(c *rux.Context) {
    c.FastSetCookie("rux_cookie2", "test-value2", 3600)
    c.SetCookie("rux_cookie", "test-value1", 3600, "/", c.Req.URL.Host, false, true)
	c.WriteString("hello, in " + c.URL().Path)
})

r.GET("/delcookie", func(c *rux.Context) {
	val := ctx.Cookie("rux_cookie") // "test-value1"
	c.DelCookie("rux_cookie", "rux_cookie2")
})

Multi Domains

code is refer from julienschmidt/httprouter

package main

import (
	"log"
	"net/http"

	"github.com/gookit/rux"
)

type HostSwitch map[string]http.Handler

// Implement the ServeHTTP method on our new type
func (hs HostSwitch) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	// Check if a http.Handler is registered for the given host.
	// If yes, use it to handle the request.
	if router := hs[r.Host]; router != nil {
		router.ServeHTTP(w, r)
	} else {
		// Handle host names for which no handler is registered
		http.Error(w, "Forbidden", 403) // Or Redirect?
	}
}

func main() {
	// Initialize a router as usual
	router := rux.New()
	router.GET("/", Index)
	router.GET("/hello/{name}", func(c *rux.Context) {})

	// Make a new HostSwitch and insert the router (our http handler)
	// for example.com and port 12345
	hs := make(HostSwitch)
	hs["example.com:12345"] = router

	// Use the HostSwitch to listen and serve on port 12345
	log.Fatal(http.ListenAndServe(":12345", hs))
}

RESETFul Style

package main

import (
	"log"
	"net/http"

	"github.com/gookit/rux"
)

type Product struct {
}

// Uses middlewares [optional]
func (Product) Uses() map[string][]rux.HandlerFunc {
	return map[string][]rux.HandlerFunc{
		// function name: handlers
		"Delete": []rux.HandlerFunc{
			handlers.HTTPBasicAuth(map[string]string{"test": "123"}),
			handlers.GenRequestID(),
		},
	}
}

// all products [optional]
func (p *Product) Index(c *rux.Context) {
	// do something
}

// create product [optional]
func (p *Product) Create(c *rux.Context) {
	// do something
}

// save new product [optional]
func (p *Product) Store(c *rux.Context) {
	// do something
}

// show product with {id} [optional]
func (p *Product) Show(c *rux.Context) {
	// do something
}

// edit product [optional]
func (p *Product) Edit(c *rux.Context) {
	// do something
}

// save edited product [optional]
func (p *Product) Update(c *rux.Context) {
	// do something
}

// delete product [optional]
func (p *Product) Delete(c *rux.Context) {
	// do something
}

func main() {
	router := rux.New()

	// methods	Path	Action	Route Name
    // GET	/product	index	product_index
    // GET	/product/create	create	product_create
    // POST	/product	store	product_store
    // GET	/product/{id}	show	product_show
    // GET	/product/{id}/edit	edit	product_edit
    // PUT/PATCH	/product/{id}	update	product_update
    // DELETE	/product/{id}	delete	product_delete
    // resetful style
	router.Resource("/", new(Product))

	log.Fatal(http.ListenAndServe(":12345", router))
}

Controller Style

package main

import (
	"log"
	"net/http"

	"github.com/gookit/rux"
)

// News controller
type News struct {
}

func (n *News) AddRoutes(g *rux.Router) {
	g.GET("/", n.Index)
	g.POST("/", n.Create)
	g.PUT("/", n.Edit)
}

func (n *News) Index(c *rux.Context) {
	// Do something
}

func (n *News) Create(c *rux.Context) {
	// Do something
}

func (n *News) Edit(c *rux.Context) {
	// Do something
}

func main() {
	router := rux.New()

	// controller style
	router.Controller("/news", new(News))

	log.Fatal(http.ListenAndServe(":12345", router))
}

Build URL

package main

import (
	"log"
	"net/http"

	"github.com/gookit/rux"
)

func main() {
	// Initialize a router as usual
	router := rux.New()
	router.GET(`/news/{category_id}/{new_id:\d+}/detail`, func(c *rux.Context) {
		var u = make(url.Values)
        u.Add("username", "admin")
        u.Add("password", "12345")
		
		b := rux.NewBuildRequestURL()
        // b.Scheme("https")
        // b.Host("www.mytest.com")
        b.Queries(u)
        b.Params(rux.M{"{category_id}": "100", "{new_id}": "20"})
		// b.Path("/dev")
        // println(b.Build().String())
        
        println(c.Router().BuildRequestURL("new_detail", b).String())
		// result:  /news/100/20/detail?username=admin&password=12345
		// get current route name
		if c.MustGet(rux.CTXCurrentRouteName) == "new_detail" {
            // post data etc....
        }
	}).NamedTo("new_detail", router)

	// Use the HostSwitch to listen and serve on port 12345
	log.Fatal(http.ListenAndServe(":12345", router))
}

Help

  • lint
golint ./...
  • format check
# list error files
gofmt -s -l ./
# fix format and write to file
gofmt -s -w some.go
  • unit test
go test -cover ./...

Gookit Packages

  • gookit/ini Go config management, use INI files
  • gookit/rux Simple and fast request router for golang HTTP
  • gookit/gcli build CLI application, tool library, running CLI commands
  • gookit/slog Concise and extensible go log library
  • gookit/event Lightweight event manager and dispatcher implements by Go
  • gookit/cache Generic cache use and cache manager for golang. support File, Memory, Redis, Memcached.
  • gookit/config Go config management. support JSON, YAML, TOML, INI, HCL, ENV and Flags
  • gookit/color A command-line color library with true color support, universal API methods and Windows support
  • gookit/filter Provide filtering, sanitizing, and conversion of golang data
  • gookit/validate Use for data validation and filtering. support Map, Struct, Form data
  • gookit/goutil Some utils for the Go: string, array/slice, map, format, cli, env, filesystem, test and more
  • More please see https://github.com/gookit

See also

License

MIT

Comments
  • build(deps): bump github.com/gookit/color from 1.5.0 to 1.5.1

    build(deps): bump github.com/gookit/color from 1.5.0 to 1.5.1

    Bumps github.com/gookit/color from 1.5.0 to 1.5.1.

    Release notes

    Sourced from github.com/gookit/color's releases.

    v1.5.1

    Change Log

    Feature

    Update

    Other

    Commits
    • bef594f chore: update pkg limit go version to 1.14+
    • 95811af chore: update the basic color preview image
    • 7ba97b3 Merge pull request #46 from gookit/dependabot/go_modules/github.com/stretchr/...
    • 2d784a3 build(deps): bump github.com/stretchr/testify from 1.7.1 to 1.7.2
    • d5924d1 up: update some for build full color string
    • 85b9eb0 feat: add more quick start func for use color
    • fb141c4 up: update action, will auto generate changelog on release
    • 374b414 Merge pull request #44 from gookit/dependabot/go_modules/github.com/stretchr/...
    • 3ec6601 build(deps): bump github.com/stretchr/testify from 1.7.0 to 1.7.1
    • ef04058 doc: add more gookit project
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies go 
    opened by dependabot[bot] 1
  • build(deps): bump github.com/gookit/goutil from 0.5.0 to 0.5.1

    build(deps): bump github.com/gookit/goutil from 0.5.0 to 0.5.1

    Bumps github.com/gookit/goutil from 0.5.0 to 0.5.1.

    Commits
    • a315a14 chore: re-generate the readme docs for timex
    • 1e8c76f test: fix timex pkg unit test error
    • 24f8ff0 feat(timex): add more util functions for timex
    • 27417e5 feat(str): add strutil.MustToTime() for force conv string to time
    • 0f4aa7c feat(timex): add more time util func
    • 51c4bd7 feat: add new func errorx.Rawf
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies go 
    opened by dependabot[bot] 1
  • url with trainling slash  /blog/100/    match  r.GET(`/blog/{id:\d+}`,

    url with trainling slash /blog/100/ match r.GET(`/blog/{id:\d+}`,

    System (please complete the following information):

    • OS: win64
    • GO Version: 1.16
    • Pkg Version: 1.3.2

    Describe the bug

    A clear and concise description of what the bug is.

    To Reproduce

    package main
    
    import (
    	"github.com/gookit/rux"
    )
    func main() {
    	r := rux.New()
    	
    	r.GET(`/blog/{id:\d+}`, func(c *rux.Context) {
            c.Text(200, "view detail, id: " + c.Param("id"))
    	})
    	r.Listen(":8080")
    }
    

    Expected behavior 404 A clear and concise description of what you expected to happen. /blog/100/ not match r.GET(/blog/{id:\d+})

    Screenshots

    If applicable, add screenshots to help explain your problem.

    Additional context

    Add any other context about the problem here.

    help wanted question 
    opened by tablecell 1
  • Bump github.com/gookit/color from 1.3.8 to 1.4.2

    Bump github.com/gookit/color from 1.3.8 to 1.4.2

    Bumps github.com/gookit/color from 1.3.8 to 1.4.2.

    Release notes

    Sourced from github.com/gookit/color's releases.

    v1.4.2

    No release notes provided.

    v1.4.1

    No release notes provided.

    v1.4.0

    Commits
    • 971acbd update readme
    • cf0234a fix tests error, strings.ReplaceAll is not work on go1.11
    • 0b651c3 update readme and fix tests error
    • b72663c feat: custom color tag support use 256,hex and rgb code
    • f683000 update readme
    • 8ce765b add more tests and update some logic
    • befe633 update some tests
    • ac48b1f update some for color detect
    • e298a5c add simple tests for quick func
    • a0e9078 up: add Set and Reset method to Color256 and RgbColor
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Bump github.com/gookit/goutil from 0.3.12 to 0.3.13

    Bump github.com/gookit/goutil from 0.3.12 to 0.3.13

    Bumps github.com/gookit/goutil from 0.3.12 to 0.3.13.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Bump github.com/gookit/color from 1.3.8 to 1.4.1

    Bump github.com/gookit/color from 1.3.8 to 1.4.1

    Bumps github.com/gookit/color from 1.3.8 to 1.4.1.

    Release notes

    Sourced from github.com/gookit/color's releases.

    v1.4.1

    No release notes provided.

    v1.4.0

    Commits
    • d37380a update readme
    • bea68e7 up: fallback on terminfo load error, simple detect by TERM value string
    • 350627c up: support disable color by NO_COLOR env
    • 22ba06a add an new method for Style
    • ba01605 update some for examples
    • 1459bf6 fix test error on windows
    • 02c98f1 up: update tests on windows OS. update readme
    • 9f91073 fix eror on github action
    • 43eff23 update github action sciprt
    • 402971f fix color level error on Terminus
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Bump github.com/gookit/color from 1.3.8 to 1.4.0

    Bump github.com/gookit/color from 1.3.8 to 1.4.0

    Bumps github.com/gookit/color from 1.3.8 to 1.4.0.

    Release notes

    Sourced from github.com/gookit/color's releases.

    v1.4.0

    Commits
    • 1459bf6 fix test error on windows
    • 02c98f1 up: update tests on windows OS. update readme
    • 9f91073 fix eror on github action
    • 43eff23 update github action sciprt
    • 402971f fix color level error on Terminus
    • aaee2b3 fix color detect error on use screen
    • f9b4cd2 update color detect logic, add more tests
    • c89242c fix: color detect tests error
    • f7f679a add more tests
    • 9e0126d fix: color detect error on win and WSL
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Bump github.com/gookit/goutil from 0.3.8 to 0.3.9

    Bump github.com/gookit/goutil from 0.3.8 to 0.3.9

    Bumps github.com/gookit/goutil from 0.3.8 to 0.3.9.

    Commits
    • 2b8584c update some for env, fs, sys utils
    • 70f68db add new sub dir
    • f791515 up: add some new methoc for map type
    • a2179c5 update osme for app logic
    • b212af4 up: add some new data type
    • d2ff7d1 Merge pull request #22 from gookit/dependabot/go_modules/github.com/gookit/co...
    • d174c4a Bump github.com/gookit/color from 1.3.6 to 1.3.7
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Save middleware auth data to *rux.Context

    Save middleware auth data to *rux.Context

    I want to save some data to Context from middleware like below Middleware.go func CheckAuth(c *rux.Context) { c.SaveDataForMainController(map[string]string{ "name": "xxxxxxxx", }) c.Next() }

    In main controller i want to access data like this Controller.go func profile(c *rux.Context) { data := c.getSavedData() }

    Is there any way to do like this or can you add features like this

    question 
    opened by ammasum 1
  • Bump github.com/gookit/validate from 1.2.5 to 1.2.7

    Bump github.com/gookit/validate from 1.2.5 to 1.2.7

    Bumps github.com/gookit/validate from 1.2.5 to 1.2.7.

    Release notes

    Sourced from github.com/gookit/validate's releases.

    v1.2.7

    No release notes provided.

    v1.2.6

    • 修复一些BUGs
    • 支持子结构体字段验证(当前仅支持二级子结构体) thanks @fishyww
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Bump github.com/gookit/goutil from 0.3.6 to 0.3.7

    Bump github.com/gookit/goutil from 0.3.6 to 0.3.7

    ⚠️ Dependabot is rebasing this PR ⚠️

    If you make any changes to it yourself then they will take precedence over the rebase.


    Bumps github.com/gookit/goutil from 0.3.6 to 0.3.7.

    Commits
    • d1680fe update en readme
    • 86fa688 add tool for gen functions map. update readme
    • e82be98 Merge branch 'master' of https://github.com/gookit/goutil
    • 20a384a update readme
    • 35ae00b Merge pull request #18 from gookit/dependabot/go_modules/github.com/gookit/co...
    • 1b37255 update some for issue template
    • 30a8334 Update issue templates
    • a4999be Bump github.com/gookit/color from 1.3.5 to 1.3.6
    • c67c779 Merge pull request #6 from gookit/dependabot/go_modules/github.com/stretchr/t...
    • ebfa60e Merge branch 'master' into dependabot/go_modules/github.com/stretchr/testify-...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • StaticFS embed的路径问题

    StaticFS embed的路径问题

    之前提的一个无法embed的问题,测试了下确实可以。但现在遇到一个embed的路径问题。 假设html的目录是static,目录下有index.html和main.js文件

    //go:embed static
    var embAssets embed.FS
    
    r.StaticFS("/", http.FS(embAssets))
    

    浏览器访问时需要输入:http://127.0.0.1:8080/static/index.html 但index.html中一般引入js的路径是http://127.0.0.1:8080/main.js 导致无法访问。所以希望在StaticFS中,能够把"static"这一层目录处理掉

    question 
    opened by ismlsmile 1
Releases(v1.3.4)
  • v1.3.4(Aug 12, 2022)

    Change Log

    • build(deps): bump github.com/gookit/goutil from 0.5.0 to 0.5.1 https://github.com/gookit/rux/commit/5e57b7d34817dcc47b059350024d4c09e4b3a80d
    • build(deps): bump github.com/gookit/goutil from 0.5.1 to 0.5.2 https://github.com/gookit/rux/commit/2b88ade8244b589cdbbeeaba3019a1fe66848d9c
    • build(deps): bump github.com/gookit/validate from 1.3.1 to 1.4.1 https://github.com/gookit/rux/commit/0c81c2be3377434c3c8b086b216a1a5aef17c21f
    • build(deps): bump github.com/stretchr/testify from 1.7.1 to 1.7.2 https://github.com/gookit/rux/commit/e01c85e9d526001e16b14fa60b459d2e0bae0111
    • build(deps): bump github.com/gookit/goutil from 0.5.2 to 0.5.4 https://github.com/gookit/rux/commit/85f574fe503e017fe6e356a17d3407c0f42799ea
    • chore: update gh workflow script and update readme https://github.com/gookit/rux/commit/5f61f421078ccf3f97fe93215ecb20ef88472365
    • chore: fix ci test error in go > 1.17 https://github.com/gookit/rux/commit/ad168452f71c8d225b2ec6ab2ec676fc3fa28c1c
    • chore: fix ci test error in gh action https://github.com/gookit/rux/commit/00cd51d399d5d11984f5d2a313e0cf5a55022ad8
    • chore: fix ci test error in gh action 2 https://github.com/gookit/rux/commit/647237bdc415c71a8d4587f4aaba29336b2c88a1
    • build(deps): bump github.com/stretchr/testify from 1.7.2 to 1.7.4 https://github.com/gookit/rux/commit/dd84fd69be4de456afa5f6b33d6aa8a86953a9af
    • build(deps): bump github.com/gookit/goutil from 0.5.4 to 0.5.5 https://github.com/gookit/rux/commit/a064b326462951d8007681f152a300c721414731
    • build(deps): bump github.com/stretchr/testify from 1.7.4 to 1.7.5 https://github.com/gookit/rux/commit/aec16db5693ac99b678b80f2a21d92bedbf05487
    • build(deps): bump github.com/gookit/validate from 1.4.1 to 1.4.2 https://github.com/gookit/rux/commit/70b66067af02a99138bb3e2873b6484632b81261
    • build(deps): bump github.com/stretchr/testify from 1.7.5 to 1.8.0 https://github.com/gookit/rux/commit/2b1aceeb2ae01a336df40c856c2145f24b9e3b0e
    • build(deps): bump github.com/gookit/goutil from 0.5.5 to 0.5.6 https://github.com/gookit/rux/commit/21379276877c46bb9ca3b3031a2ac308445d0656
    • build(deps): bump github.com/gookit/goutil from 0.5.6 to 0.5.7 https://github.com/gookit/rux/commit/306198e98b9651c13db31bdf962073c329264f35
    • build(deps): bump morphy2k/revive-action from 2.3.1 to 2.4.0 https://github.com/gookit/rux/commit/8e3bc76725acdba94c9df47963b691339fa8d7c3
    • build(deps): bump github.com/gookit/goutil from 0.5.7 to 0.5.8 https://github.com/gookit/rux/commit/1a6b4028f98cbaa977e8fdbe4870128c4400a4b4
    • chore: update go version and release action https://github.com/gookit/rux/commit/f28f9356a6fed7f8965b7fc93993e37ca32989dd
    • chore: update the serve examples, update readme https://github.com/gookit/rux/commit/b00b7b3f2a5ce28b96c8af6cade6999a276b64c4
    • chore: add tests on go1.19, remote test on go1.15 https://github.com/gookit/rux/commit/a0430a94180721d11f1aede074f2c0a8a25aa31f
    • chore: add codeql.yml action for check codes https://github.com/gookit/rux/commit/efde02f24e222d9510904f177b609fddd14f2aee
    • test: fix unit tests error on gh action https://github.com/gookit/rux/commit/c4a59d4af3778b10e430621e99923995b520a8e0
    Source code(tar.gz)
    Source code(zip)
  • v1.3.3(Apr 14, 2022)

    Change Log

    Update

    • up: optimize some memory alloc logic https://github.com/gookit/rux/commit/4ff59e9c9e715085a992175e38282dece55d0ef1
    • update readme, add an issues test file https://github.com/gookit/rux/commit/e2b05ab6cc12b7ef78923e190066e8c606760178
    • prof: simple profile some mem alloc https://github.com/gookit/rux/commit/5acbc732d4727fd339e9245095c5e4fc02f78f98
    • update .github/dependabot.yml https://github.com/gookit/rux/commit/e2c699ae5c1fa181ea8d892ca4f052b491fb8b29
    • add some new method alias, will not support go 1.13 https://github.com/gookit/rux/commit/9627aa48d1aa28c7e30571ea0ce0a4429422524b
    • update: add tests on go1.18 and move go1.14 https://github.com/gookit/rux/commit/3035fbe99e708fcce0aaf1a022234089697e9d58

    Fixed

    • fix some comments error https://github.com/gookit/rux/commit/4ac815345972ad7d4443b596b2e06744ad9a87f2
    • fix: assert serve static file content type error https://github.com/gookit/rux/commit/f5f453b4f68172e22190cd16b4c69a1fd91c0d76

    Other

    • Bump github.com/gookit/goutil from 0.3.13 to 0.3.14 https://github.com/gookit/rux/commit/96c5024075f360537cbcdc6734a5a629a8dadb56
    • Bump github.com/gin-gonic/gin from 1.6.3 to 1.7.0 in /_benchmarks https://github.com/gookit/rux/commit/d96d30844556a79e69714ad3141079bb78b072d5
    • Bump github.com/gookit/goutil from 0.3.14 to 0.3.15 https://github.com/gookit/rux/commit/d9d5813088c4fc3fd4130b73b5ffb3e4e0212840
    • Bump github.com/gookit/color from 1.4.2 to 1.5.0 https://github.com/gookit/rux/commit/16b7ae2831895da5fc64453af332f4e2bdd769ac
    • Bump github.com/gookit/goutil from 0.3.15 to 0.4.0 https://github.com/gookit/rux/commit/b6d072da17d1ce89356d7441b958a0aaf4ed634d
    • Bump github.com/gookit/goutil from 0.4.0 to 0.4.1 https://github.com/gookit/rux/commit/db03039e2975e09f5fdbdac9a9cb8fe7084a5057
    • Bump github.com/gookit/goutil from 0.4.1 to 0.4.2 https://github.com/gookit/rux/commit/22a1c84ea027913e415c8e829475a03baf7b1bc2
    • Bump github.com/gookit/goutil from 0.4.2 to 0.4.4 https://github.com/gookit/rux/commit/0bc8d2310f9361e8a5225072fc32d13b270f0031
    • Bump github.com/gorilla/websocket from 1.4.2 to 1.5.0 https://github.com/gookit/rux/commit/926ed7bc8abd1bf87859cd0782b313509f5f8776
    • Bump actions/checkout from 2 to 3 https://github.com/gookit/rux/commit/5821af86b8b19e4abbd893ae544608886d59a8cc
    • Bump github.com/gookit/validate from 1.2.11 to 1.3.0 https://github.com/gookit/rux/commit/9bedd3ab3852acedf860c378b1419112f782799d
    • Bump github.com/gookit/validate from 1.3.0 to 1.3.1 https://github.com/gookit/rux/commit/1fb959996351809763885c55c8d86c45d4201ec5
    • Bump github.com/stretchr/testify from 1.7.0 to 1.7.1 https://github.com/gookit/rux/commit/62c5abeef196c1a2dbb789ad93737fab2231fb5e
    • Bump github.com/valyala/fasthttp from 1.15.1 to 1.34.0 in /_benchmarks https://github.com/gookit/rux/commit/d2b04703fac62e254fe0fe8bfc7c49ea13503acc
    • Bump github.com/gookit/goutil from 0.4.4 to 0.4.5 https://github.com/gookit/rux/commit/2243835f8421ceeaa88bc4d82a2a3eeeed30cd6c
    • Bump github.com/gookit/goutil from 0.4.5 to 0.4.6 https://github.com/gookit/rux/commit/066f4effd925504280275e22603889402fb5cdae
    • Bump actions/setup-go from 2 to 3 https://github.com/gookit/rux/commit/8bad1410896a2cf31e2902be8308a89204c1338c
    • chore: update some deps version https://github.com/gookit/rux/commit/8312da71867b442b5b89cabc831c45c63657c403
    • chore: update valyala/fasthttp version to v1.35.0 https://github.com/gookit/rux/commit/24fe0335546f8f59693dd8afaafe22a10fbc2b82
    Source code(tar.gz)
    Source code(zip)
  • v1.3.2(Apr 12, 2021)

  • v1.3.1(Dec 11, 2020)

  • v1.3.0(Sep 12, 2020)

    Update

    NOTICE: v1.3.x is not fully compatible with v1.2.x version

    • refacting data binding and response render logic
    • modify route match return
    • limit mini go version is 1.13
    • fix some errors
    Source code(tar.gz)
    Source code(zip)
  • v1.2.10(Sep 11, 2020)

  • v1.2.9(Aug 8, 2020)

  • v1.2.8(Jul 25, 2020)

  • v1.2.7(Jul 5, 2020)

  • v1.2.6(Jun 23, 2020)

  • v1.2.5(Jan 2, 2020)

  • v1.2.4(Aug 30, 2019)

  • v1.2.1(Aug 3, 2019)

  • v1.2.0(Aug 1, 2019)

  • v1.1.5(Aug 1, 2019)

  • v1.1.4(Jul 28, 2019)

  • v1.1.3(Mar 10, 2019)

  • v1.0.0(Aug 30, 2018)

Owner
Gookit
Useful libs for the Go(router, DI, log, config, cache, event, validate, filter, CLI, i18n, respond-data, view-render)
Gookit
Muxie is a modern, fast and light HTTP multiplexer for Go. Fully compatible with the http.Handler interface. Written for everyone.

Muxie ?? ?? ?? ?? ?? ?? Fast trie implementation designed from scratch specifically for HTTP A small and light router for creating sturdy backend Go a

Gerasimos (Makis) Maropoulos 277 Sep 24, 2022
Gin middleware/handler to enable CORS support.

wcors Gin middleware/handler to enable CORS support. Usage Start using it Download and install it: go get github.com/wyy-go/wcors Import it in your co

null 0 Jan 8, 2022
henrylee2cn 1.6k Sep 16, 2022
This library provides a simple framework of microservice, which includes a configurator, a logger, metrics, and of course the handler

Microservice The framework for the creation of microservices, written in Golang. (note: http microservice) Architecture microservice includes: handle

Eduard 102 Aug 30, 2022
Timeout handler for http request in Gin framework

Middleware to Handle Request Timeout in Gin Installation Installation go get github.com/s-wijaya/gin-timeout Import it in your code: import ( // o

Saptari Wijaya 0 Dec 14, 2021
Goa is a web framework based on middleware, like koa.js.

Goa Goa is under construction, if you are familiar with koa or go and interested in this project, please join us. What is goa? goa = go + koa Just lik

null 46 May 17, 2022
Bootstrapper and middleware for Echo framework in golang.

rk-echo Interceptor & bootstrapper designed for echo framework. Currently, supports bellow functionalities. Name Description Start with YAML Start ser

PointGoal 5 Jul 9, 2022
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.

Flamingo Framework Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Flamingo 312 Sep 14, 2022
hiboot is a high performance web and cli application framework with dependency injection support

Hiboot - web/cli application framework About Hiboot is a cloud native web and cli application framework written in Go. Hiboot is not trying to reinven

hidevops.io 177 Aug 27, 2022
Golanger Web Framework is a lightweight framework for writing web applications in Go.

/* Copyright 2013 Golanger.com. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

golanger 299 Mar 3, 2022
The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework.

jin About The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework. If thi

null 8 Jul 14, 2022
Fast and Reliable Golang Web Framework

Gramework The Good Framework Gramework long-term testing stand metrics screenshot made with Gramework Stats Dashboard and metrics middleware What is i

null 371 Sep 19, 2022
⚡Simple cors middleware package for minima

This is package is wrapper based on rs/cors package made for minima. Geting Started Install the package using go get github.com/gominima/cors and call

Minima 5 Mar 7, 2022
Golang based tools for taking PC-compatible ELFs and generating fake SELFs that run on the PlayStation 4.

Tool Documentation (create-fself) Summary create-fself can be used to take 64-bit ELF files and produce fake Signed ELFs that can be used on the PlayS

null 5 Aug 14, 2022
Gerasimos (Makis) Maropoulos 22.9k Sep 21, 2022
Gzip Middleware for Go

An out-of-the-box, also customizable gzip middleware for Gin and net/http.

LI Zhennan 128 Sep 8, 2022
Prometheus middleware for wish

promwish Package promwish provides a simple wish middleware exposing some Prometheus metrics. Example Usage You can add promwish as a middleware to yo

Charm 28 Sep 1, 2022
X-Response-Time middleware for fiber/v2

fiber-responsetime X-Response-Time middleware for fiber/v2 go get github.com/husanu/fiber-responsetime/v2 package main import ( "time" "github.com

Andrei Husanu 0 Dec 17, 2021
Auth0 Middleware for go labstack/echo

go-echo-auth0-middleware Auth0 Middleware for go labstack/echo Example package main import ( "net/http" "github.com/auth0/go-jwt-middleware/v2/val

Satish Babariya 6 Jul 7, 2022