-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
58 lines (51 loc) · 1.71 KB
/
server.go
File metadata and controls
58 lines (51 loc) · 1.71 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"net/http"
)
var servers [4]TFSServer
var credentials [4]TFSCredentials
var indexHandler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Testing")
}
var editHandler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
account := r.FormValue("account")
project := r.FormValue("project")
build := r.FormValue("build")
username := r.FormValue("username")
password := r.FormValue("password")
domain := r.FormValue("domain")
switch r.FormValue("index") {
case "1":
servers[0] = TFSHostedServer{account, TFSBuildDefinition{"", project, build}}
credentials[0] = TFSCredentials{username, password, domain}
fmt.Println("Updated server:", servers[0])
fmt.Println("Updated credentials:", credentials[0])
break
case "2":
servers[1] = TFSHostedServer{account, TFSBuildDefinition{"", project, build}}
credentials[1] = TFSCredentials{username, password, domain}
fmt.Println("Updated server:", servers[1])
fmt.Println("Updated credentials:", credentials[1])
break
case "3":
servers[2] = TFSHostedServer{account, TFSBuildDefinition{"", project, build}}
credentials[2] = TFSCredentials{username, password, domain}
fmt.Println("Updated server:", servers[2])
fmt.Println("Updated credentials:", credentials[2])
break
case "4":
servers[3] = TFSHostedServer{account, TFSBuildDefinition{"", project, build}}
credentials[3] = TFSCredentials{username, password, domain}
fmt.Println("Updated server:", servers[3])
fmt.Println("Updated credentials:", credentials[3])
break
}
}
func startServer(exit <-chan bool) {
http.Handle("/", indexHandler)
http.Handle("/edit", editHandler)
go http.ListenAndServe(":8080", nil)
<-exit
}