-
Notifications
You must be signed in to change notification settings - Fork 3
/
env.go
34 lines (30 loc) · 847 Bytes
/
env.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
package inngestgo
import (
"net/url"
"os"
)
const (
devServerURL = "http://127.0.0.1:8288"
)
// IsDev returns whether to use the dev server, by checking the presence of the INNGEST_DEV
// environment variable.
//
// To use the dev server, set INNGEST_DEV to any non-empty value OR the URL of the development
// server, eg:
//
// INNGEST_DEV=1
// INNGEST_DEV=http://192.168.1.254:8288
func IsDev() bool {
return os.Getenv("INNGEST_DEV") != ""
}
// DevServerURL returns the URL for the Inngest dev server. This uses the INNGEST_DEV
// environment variable, or defaults to 'http://127.0.0.1:8288' if unset.
func DevServerURL() string {
if dev := os.Getenv("INNGEST_DEV"); dev != "" {
if u, err := url.Parse(dev); err == nil && u.Host != "" {
// Only return this if it's a valid URL.
return dev
}
}
return devServerURL
}