-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
config_controller.go
54 lines (46 loc) · 1.08 KB
/
config_controller.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
package web
import (
"fmt"
"net/http"
"strconv"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/utils"
"github.com/gin-gonic/gin"
)
// ConfigController manages config variables
type ConfigController struct {
App chainlink.Application
}
// Show returns the whitelist of config variables
// Example:
//
// "<application>/config"
func (cc *ConfigController) Show(c *gin.Context) {
cfg := cc.App.GetConfig()
var userOnly bool
if s, has := c.GetQuery("userOnly"); has {
var err error
userOnly, err = strconv.ParseBool(s)
if err != nil {
jsonAPIError(c, http.StatusBadRequest, fmt.Errorf("invalid bool for userOnly: %v", err))
return
}
}
var toml string
user, effective := cfg.ConfigTOML()
if userOnly {
toml = user
} else {
toml = effective
}
jsonAPIResponse(c, ConfigV2Resource{toml}, "config")
}
type ConfigV2Resource struct {
Config string `json:"config"`
}
func (c ConfigV2Resource) GetID() string {
return utils.NewBytes32ID()
}
func (c *ConfigV2Resource) SetID(string) error {
return nil
}