/gorouter

Go Server/API micro framwework, HTTP request router, multiplexer, mux

Primary LanguageGoMIT LicenseMIT

Vardius - gorouter

Build Status Go Report Card codecov license Beerpay Beerpay

Go Server/API micro framwework, HTTP request router, multiplexer, mux.

ABOUT

Contributors:

Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas? We are using the github issue tracker to manage them.

HOW TO USE

  1. GoDoc
  2. Documentation
  3. Benchmarks
  4. Go Server/API boilerplate using best practices DDD CQRS ES

Basic example

package main

import (
    "fmt"
    "log"
    "net/http"
	
    "github.com/vardius/gorouter"
)

func Index(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "Welcome!\n")
}

func Hello(w http.ResponseWriter, r *http.Request) {
    params, _ := gorouter.FromContext(r.Context())
    fmt.Fprintf(w, "hello, %s!\n", params.Value("name"))
}

func main() {
    router := gorouter.New()
    router.GET("/", http.HandlerFunc(Index))
    router.GET("/hello/{name}", http.HandlerFunc(Hello))

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

Advanced examples

License

This package is released under the MIT license. See the complete license in the package:

LICENSE