forked from gramework/gramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_listenAndServeAll.go
28 lines (26 loc) · 969 Bytes
/
app_listenAndServeAll.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
package gramework
// ListenAndServeAll serves HTTP and HTTPS automatically.
// HTTPS is served on :443.
// If it can't serve http or https, it logs an error and
// exit the server with app.Logger.Fatalf().
func (app *App) ListenAndServeAll(httpAddr ...string) {
go func() {
err := app.ListenAndServeAutoTLS(":443")
app.Logger.Fatalf("can't serve tls: %s", err)
}()
err := app.ListenAndServe(httpAddr...)
app.Logger.Fatalf("can't serve http: %s", err)
}
// ListenAndServeAllDev serves HTTP and HTTPS automatically
// with localhost HTTPS support via self-signed certs.
// HTTPS is served on :443.
// If it can't serve http or https, it logs an error and
// exit the server with app.Logger.Fatalf().
func (app *App) ListenAndServeAllDev(httpAddr ...string) {
go func() {
err := app.ListenAndServeAutoTLSDev(":443")
app.Logger.Fatalf("can't serve tls: %s", err)
}()
err := app.ListenAndServe(httpAddr...)
app.Logger.Fatalf("can't serve http: %s", err)
}