forked from dikhan/terraform-provider-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (31 loc) · 802 Bytes
/
main.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
package main
import (
"log"
"net/http"
sw "github.com/dikhan/terraform-provider-openapi/examples/swaggercodegen/api/api"
)
func main() {
errs := make(chan error)
router := sw.NewRouter()
// Starting HTTP server
go func() {
addr := ":80"
log.Printf("Staring HTTP service on %s ...", addr)
if err := http.ListenAndServe(addr, router); err != nil {
errs <- err
}
}()
// Starting HTTPS server
go func() {
sslAddr := ":443"
log.Printf("Staring HTTPS service on %s ...", sslAddr)
if err := http.ListenAndServeTLS(sslAddr, "ssl/certificate.crt", "ssl/privateKey.key", router); err != nil {
errs <- err
}
}()
// This will run forever until channel receives error
select {
case err := <-errs:
log.Printf("Could not start serving service due to (error: %s)", err)
}
}