-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflowserver.go
60 lines (48 loc) · 1.24 KB
/
workflowserver.go
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
59
60
package server
import (
"fmt"
"log"
"net/http"
goclient "github.com/ditrit/gandalf/libraries/goclient"
"github.com/go-chi/chi"
)
const (
server_address = "localhost"
server_port = ":3011"
)
type WorkflowServer struct {
address string
port string
router *chi.Mux
controller *WorkflowController
Rooturl string
Url urls
b *Broker
}
func NewWorkflowServer(clientGandalf *goclient.ClientGandalf) *WorkflowServer {
formServer := new(WorkflowServer)
formServer.address = server_address
formServer.port = server_port
formServer.Rooturl = server_address + server_port
formServer.b = &Broker{
make(map[chan string]bool),
make(chan (chan string)),
make(chan (chan string)),
make(chan string),
}
formServer.Url = ReturnURLS()
fmt.Println("toto0")
formServer.controller = NewWorkflowController(clientGandalf, formServer.b)
//formServer.router = GetRouter(formServer.controller)
fmt.Println("toto2")
formServer.router = GetRouter(formServer.controller)
fmt.Println("toto3")
return formServer
}
func (f WorkflowServer) Run() {
f.b.Start()
http.Handle("/events/", f.b)
// Start the server
log.Printf("Listening on localhost: %s", f.port)
log.Println(http.ListenAndServe(f.Rooturl, f.router))
}