24 lines
421 B
Go
24 lines
421 B
Go
|
package switchcounter
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
r "gopkg.in/rethinkdb/rethinkdb-go.v6"
|
||
|
)
|
||
|
|
||
|
type Switches struct {
|
||
|
session *r.Session
|
||
|
}
|
||
|
|
||
|
func New(session *r.Session, mux *http.ServeMux) *Switches {
|
||
|
result := &Switches{
|
||
|
session: session,
|
||
|
}
|
||
|
|
||
|
mux.HandleFunc("/switches/", result.GetSwitches)
|
||
|
mux.HandleFunc("/switches/current", result.Current)
|
||
|
mux.HandleFunc("/switches/switch", result.RegisterSwitch)
|
||
|
|
||
|
return result
|
||
|
}
|