-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathconfig.go
48 lines (42 loc) · 1.32 KB
/
config.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
package core
import (
"net/url"
"strings"
)
func GetURL(Map map[string]interface{}) string {
return Map["URL"].(string)
}
func GetHeader(Map map[string]interface{}) map[string]string {
return Map["Header"].(map[string]string)
}
func GetOutput(Bytes []byte) []byte {
Info := PullInfo["Output"].(map[string]string)
Data := Bytes[ToLength(Info["Prepend"]):len(Bytes)-ToLength(Info["Append"])]
return Decoding(string(Data), Info["Coding"])
}
func SetOutput(Bytes []byte) *strings.Reader {
Info := PushInfo["Output"].(map[string]string)
Data := Info["Prepend"] + Encoding(Bytes, Info["Coding"]) + Info["Append"]
return strings.NewReader(Data)
}
func SetProperty(Map map[string]interface{}, Key string, Value []byte) {
URL, _ := url.Parse(GetURL(Map))
Header := Base64ToMap(Map["Header"].(string))
KeyMap := Map[Key].(map[string]string)
KeyInfo := strings.SplitN(KeyMap["Store"], ":", 2)
KeyData := KeyMap["Prepend"] + Encoding(Value, KeyMap["Coding"]) + KeyMap["Append"]
if strings.ToUpper(KeyInfo[0]) == "URL" {
if len(KeyInfo) == 2 && len(KeyInfo[1]) > 0 {
Query := URL.Query()
Query.Set(KeyInfo[1], KeyData)
URL.RawQuery = Query.Encode()
} else {
URL.Path = URL.Path + KeyData
}
}
if strings.ToUpper(KeyInfo[0]) == "HEADER" {
Header[KeyInfo[1]] = KeyData
}
Map["URL"] = URL.String()
Map["Header"] = Header
}