Skip to content

Releases: gossie/router

v1.0.0-beta.2

13 Mar 10:20
c7c444f
Compare
Choose a tag to compare
v1.0.0-beta.2 Pre-release
Pre-release

What's Changed

Full Changelog: v1.0.0-beta.1...v1.0.0-beta.2

v1.0.0-beta.1

27 Jul 19:26
ef642e8
Compare
Choose a tag to compare
v1.0.0-beta.1 Pre-release
Pre-release

What's Changed

  • Update README.md by @gossie in #6
  • #5 apply middleware functions for single routes by @gossie in #7
  • #9 transforms static route elements to lower case by @gossie in #10
  • Feature/8 apply middleware functions for group of routes by @gossie in #11
  • #12 reduces allocations by @gossie in #14
  • Refactor/12 perform benchmark by @gossie in #15

Full Changelog: v0.2.0...v1.0.0-beta.1

v0.2.0

13 Jul 22:19
cf13bc4
Compare
Choose a tag to compare
v0.2.0 Pre-release
Pre-release
  • Middleware function to support basic auth
import (
    "net/http"

    "github.com/gossie/router"
)

func main() {
    userChecker := func(us *router.UserData) bool {
        // TODO: check the UserData and return true if username and password matches, false otherwise
    }

    httpRouter := router.New()

    httpRouter.Get("/books", getBooksHandler)
    httpRouter.Post("/books", createBookHandler)
    httpRouter.Get("/books/:bookId", getSingleBookHandler)

    httpRouter.Use(router.BasicAuth(userChecker))

    log.Fatal(http.ListenAndServe(":8080", httpRouter))
}
  • Middleware function to set headers for browser caching
import (
    "net/http"

    "github.com/gossie/router"
)

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

    httpRouter.Get("/books", getBooksHandler)
    httpRouter.Post("/books", createBookHandler)
    httpRouter.Get("/books/:bookId", getSingleBookHandler)

    httpRouter.Use(router.Cache(1 * time.Hour))

    log.Fatal(http.ListenAndServe(":8080", httpRouter))
}

v0.1.0

13 Jul 22:14
96750d5
Compare
Choose a tag to compare
v0.1.0 Pre-release
Pre-release
  • Support custom middleware functions
import (
    "net/http"

    "github.com/gossie/router"
)

func logRequestTime(handler router.HttpHandler) router.HttpHandler {
    return func(w http.ResponseWriter, r *http.Request, m map[string]string) {
        start := time.Now()
        defer func() {
            log.Default().Println("request took", time.Since(start).Milliseconds(), "ms")
        }()

        handler(w, r, m)
    }
}

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

    httpRouter.Get("/books", getBooksHandler)
    httpRouter.Post("/books", createBookHandler)
    httpRouter.Get("/books/:bookId", getSingleBookHandler)

    httpRouter.Use(logRequestTime)

    log.Fatal(http.ListenAndServe(":8080", httpRouter))
}

v0.0.1

13 Jul 22:10
Compare
Choose a tag to compare
v0.0.1 Pre-release
Pre-release
  • Router distinguishes between HTTP methods
  • Routes can contain path variables