blob: a8ede7363d07e9e198f60a150674ee1d9eb984a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package backend
import (
"log"
"net/http"
)
/* mock http server: easy way to mocking vpn behavior on ui interaction. This
* should also show a good way of writing functionality tests just for the Qml
* layer */
func mockUIOn(w http.ResponseWriter, r *http.Request) {
log.Println("changing status: on")
setStatus(on)
}
func mockUIOff(w http.ResponseWriter, r *http.Request) {
log.Println("changing status: off")
setStatus(off)
}
func mockUIFailed(w http.ResponseWriter, r *http.Request) {
log.Println("changing status: failed")
setStatus(failed)
}
func mockUI() {
http.HandleFunc("/on", mockUIOn)
http.HandleFunc("/off", mockUIOff)
http.HandleFunc("/failed", mockUIFailed)
http.ListenAndServe(":8080", nil)
}
|