Skip to content

Commit

Permalink
/improved condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicerobot committed Nov 27, 2016
1 parent 72ef775 commit 7e904c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 2 additions & 0 deletions design/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var _ = API("opinionated", func() {
Description("A basic starter service")
Scheme("http")
Host("localhost:3080")
Consumes("application/json")
Produces("application/json")
})

var _ = Resource("user", func() {
Expand Down
28 changes: 12 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,26 @@ func main() {
pubPort = strconv.Itoa(Settings.Port - 363)
}

addr := Settings.Addr + ":" + pubPort

if !Settings.Secure {

stderr.Printf("HTTP %s\n", addr)
return service.ListenAndServe(addr)

} else {
switch Settings.Secure {
case true:
crt := filepath.Join(Settings.Program.Data, "server.crt")
key := filepath.Join(Settings.Program.Data, "server.key")

if _, err := tls.LoadX509KeyPair(crt, key); err != nil {
stderr.Println(err)

stderr.Printf("HTTP %s\n", addr)
return service.ListenAndServe(addr)

} else {

_, err := tls.LoadX509KeyPair(crt, key)
if err == nil {
addr := Settings.Addr + ":" + privPort
stderr.Printf("HTTPS %s\n", addr)
return service.ListenAndServeTLS(addr, crt, key)
}
stderr.Println(err)
fallthrough

case false:
addr := Settings.Addr + ":" + pubPort
stderr.Printf("HTTP %s\n", addr)
return service.ListenAndServe(addr)
}
return nil
},
},
}
Expand Down
Binary file modified opinionated
Binary file not shown.

0 comments on commit 7e904c9

Please sign in to comment.