github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/httpclient/init.go (about) 1 package httpclient 2 3 import ( 4 "github.com/lmorg/murex/app" 5 "github.com/lmorg/murex/config" 6 "github.com/lmorg/murex/lang" 7 "github.com/lmorg/murex/lang/types" 8 ) 9 10 func init() { 11 lang.DefineMethod("get", cmdGet, types.Any, types.Json) 12 lang.DefineFunction("getfile", cmdGetFile, types.Any) 13 lang.DefineMethod("post", cmdPost, types.Any, types.Json) 14 15 config.InitConf.Define("http", "user-agent", config.Properties{ 16 Description: "User agent string for `get` and `getfile`.", 17 Default: app.Name + "/" + app.Version(), 18 DataType: types.String, 19 }) 20 21 config.InitConf.Define("http", "timeout", config.Properties{ 22 Description: "Timeout in seconds for `get` and `getfile`.", 23 Default: 10, 24 DataType: types.Integer, 25 }) 26 27 config.InitConf.Define("http", "insecure", config.Properties{ 28 Description: "Ignore certificate errors.", 29 Default: false, 30 DataType: types.Boolean, 31 }) 32 33 config.InitConf.Define("http", "redirect", config.Properties{ 34 Description: "Automatically follow redirects.", 35 Default: true, 36 DataType: types.Boolean, 37 }) 38 39 config.InitConf.Define("http", "default-https", config.Properties{ 40 Description: "If true then when no protocol is specified (`http://` nor `https://`) then default to `https://`.", 41 Default: false, 42 DataType: types.Boolean, 43 }) 44 45 config.InitConf.Define("http", "cookies", config.Properties{ 46 Description: "Defined cookies to send, ordered by domain.", 47 Default: metaDomains{ 48 "example.com": metaValues{"name": "value"}, 49 "www.example.com": metaValues{"name": "value"}, 50 }, 51 DataType: types.Json, 52 }) 53 54 config.InitConf.Define("http", "headers", config.Properties{ 55 Description: "Defined HTTP request headers to send, ordered by domain.", 56 Default: metaDomains{ 57 "example.com": metaValues{"name": "value"}, 58 "www.example.com": metaValues{"name": "value"}, 59 }, 60 DataType: types.Json, 61 }) 62 }