example router
[VSCPweb/.git] / main.go
1 package main
2
3 import (
4         "fmt"
5         "net/http"
6
7         "github.com/gorilla/mux"
8 )
9
10 func main() {
11
12     //example of simple http router, fased out in favor of gorilla mux
13         //http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
14                 //fmt.Fprintf(w, "Hello World!")
15         //})
16         //http.ListenAndServe(":8000", nil)
17
18
19
20     r := mux.NewRouter()
21     r.HandleFunc("/example/{first}/{second:[0-9]+}", exampleHandler)
22     //r.HandleFunc("/", )
23     //r.HandleFunc("/access", )
24     //r.HandleFunc("/stats", )
25     //r.HandleFunc("/topology", )
26     //r.HandleFunc("/health", )
27     //r.HandleFunc("/free", )//probably do this with server side or sockets
28     //r.HandleFunc("/flowdel", )//this is an external request
29     //r.HandleFunc("/mpstat", )
30     //r.HandleFunc("/ifstat", )
31     //r.HandleFunc("/showtemp", )
32     //r.HandleFunc("/gettopo", )
33     //r.HandleFunc("/net", )
34     //r.HandleFunc("/rpiping", )//workerping
35     //r.HandleFunc("/nodes", )
36     //r.HandleFunc("/statusnodes", )
37     //r.HandleFunc("/intfs", )
38     //r.HandleFunc("/iperf", )
39     //r.HandleFunc("/pingall", )
40     //r.HandleFunc("/placement", )
41     //r.HandleFunc("/getvsorcdata", )
42     //r.HandleFunc("/getcontrollerdata", )
43     //r.HandleFunc("/resetflows", )
44     //r.HandleFunc("/listswitch", )
45     //r.HandleFunc("/status", )
46     //r.HandleFunc("/tablestatus", )
47     //r.HandleFunc("/portsdesc", )
48     //r.HandleFunc("/portsstat", )
49     //r.HandleFunc("/startcontroller", )
50     //r.HandleFunc("/startcontrollerrouter", )
51     //r.HandleFunc("/stopcontroller", )
52     //r.HandleFunc("/sendcommand", )
53     //r.HandleFunc("/cancel", )
54     //r.HandleFunc("/startvsorc", )
55     //r.HandleFunc("/stopvsorc", )
56     http.Handle("/", r)
57     http.ListenAndServe(":8000", nil)
58
59
60
61 }
62
63 func exampleHandler(w http.ResponseWriter, r *http.Request) {
64     vars := mux.Vars(r)
65     w.WriteHeader(http.StatusOK)
66     fmt.Fprintf(w, "First: %v\nSecond: %v", vars["first"], vars["second"])
67 }