Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 510 Bytes

full-example.md

File metadata and controls

26 lines (20 loc) · 510 Bytes

Full Example

Here's a complete, runnable example of a small mux based server:

package main

import (
    "net/http"
    "log"
    mux "github.com/vaguecoder/gorilla-mux"
)

func YourHandler(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("Gorilla!\n"))
}

func main() {
    r := mux.NewRouter()
    // Routes consist of a path and a handler function.
    r.HandleFunc("/", YourHandler)

    // Bind to a port and pass our router in
    log.Fatal(http.ListenAndServe(":8000", r))
}