/
server.go
53 lines (43 loc) · 1.68 KB
/
server.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
package server
import (
"database/sql"
"io/ioutil"
"strings"
)
// API is used to store the database pointer
type API struct {
DB *sql.DB
Connector Connector
DataDir string
HomeDir string
RelayNode string
RelayNodeTestUser string
RelayNodeTestUserPassword string
QaasHost string
QaasInternalPort string // Port for internal use
QaasExternalPort string // Port for the outside world
PrivateKeyFilename string
PublicKeyFilename string
}
// WebhookPath is the basic part of the webhook payload URL
const WebhookPath = "/webhook"
// WebhookPostPath is the first part of the webhook payload URL [POST]
const WebhookPostPath = "/webhook/{webhook}"
// ConfigurationPath is the basic URL path for configuring the qaas server
const ConfigurationPath = "/configuration"
// ConfigurationAddPath is the URL path to add a new webhook [PUT]
const ConfigurationAddPath = "/configuration"
// ConfigurationListPath is the URL path to list all webhook for a certain user [GET]
const ConfigurationListPath = "/configuration"
// ConfigurationInfoPath is the URL path to get detailed information about a certain webhook [GET]
const ConfigurationInfoPath = "/configuration/{webhook}"
// ConfigurationDeletePath is the URL path to delete a certain webhook [DELETE]
const ConfigurationDeletePath = "/configuration/{webhook}"
// RunsWithinContainer checks if the program runs in a Docker container or not
func RunsWithinContainer() bool {
file, err := ioutil.ReadFile("/proc/1/cgroup")
if err != nil {
return false
}
return strings.Contains(string(file), "docker")
}