diff --git a/design/api.go b/design/api.go index c9b3230..3e46d47 100644 --- a/design/api.go +++ b/design/api.go @@ -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() { diff --git a/main.go b/main.go index 76ebc00..a65cb37 100644 --- a/main.go +++ b/main.go @@ -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 }, }, } diff --git a/opinionated b/opinionated index bfe128e..f49ba5e 100755 Binary files a/opinionated and b/opinionated differ