package
0.0.0-20171026202257-962f6387c1f8
Repository: https://github.com/manyminds/api2go-adapter.git
Documentation: pkg.go.dev
# README
Gorilla mux Router Adapter
This adapter must be used in combination with api2go in order to be useful. It allows you to use api2go within your Gorilla mux application.
Example
package main
import (
"github.com/gorilla/mux"
"github.com/manyminds/api2go"
"github.com/manyminds/api2go-adapter/gorillamux"
"net/http"
)
func main() {
r := mux.NewRouter()
api := api2go.NewAPIWithRouting(
"api",
api2go.NewStaticResolver("/"),
api2go.DefaultContentMarshalers,
gorillamux.New(r),
)
// Add your API resources here...
// see https://github.com/manyminds/api2go for more information
r.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write("pong")
}).Methods("GET")
http.Handle("/", r)
}
# Functions
New creates a new api2go router to use with the Gorilla mux framework.