gorillamux

package
v0.0.0-...-59909aa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2017 License: MIT Imports: 5 Imported by: 0

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)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(gm *mux.Router) routing.Routeable

New creates a new api2go router to use with the Gorilla mux framework

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL