-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
connect_url.go
57 lines (49 loc) · 1.37 KB
/
connect_url.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2021-22 Kirill Scherba <[email protected]>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Teonet connect URL module
package teonet
import "os"
const (
verURL = "v5"
proURL = "https://teonet.cloud"
devURL = "http://dev.myteo.net:10000"
)
// connectURL connect URL struct and method receiver
type connectURL struct {
authURL, rauthURL, rauthPage string
}
// newConnectURL create new connectURL and make auth connectr URLs
func (teo *Teonet) newConnectURL() {
teo.connectURL = new(connectURL)
teo.connectURL.makeURLs()
}
// makeURLs make auth connectr URLs
func (c *connectURL) makeURLs() {
// make URLs
const fullDevURL = devURL + "/" + verURL + "/"
const fullProdURL = proURL + "/" + verURL + "/"
// auth
const authPage = "auth"
const authProdURL = fullProdURL + authPage
const authDevURL = fullDevURL + authPage
// rauth
c.rauthPage = "rauth"
rauthProdURL := fullProdURL + c.rauthPage
rauthDevURL := fullDevURL + c.rauthPage
// auth & rauth depend of TEOENV mode, if TEOENV=dev than dev mode
if c.devMode() {
c.authURL = authDevURL
c.rauthURL = rauthDevURL
} else {
c.authURL = authProdURL
c.rauthURL = rauthProdURL
}
}
// devMode return true in development mode
func (c *connectURL) devMode() (ok bool) {
if os.Getenv("TEOENV") == "dev" {
ok = true
}
return
}