{"action":"created","issue":{"url":"https://api.github.com/repos/hooklift/gowsdl/issues/106","repository_url":"https://api.github.com/repos/hooklift/gowsdl","labels_url":"https://api.github.com/repos/hooklift/gowsdl/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/hooklift/gowsdl/issues/106/comments","events_url":"https://api.github.com/repos/hooklift/gowsdl/issues/106/events","html_url":"https://github.com/hooklift/gowsdl/issues/106","id":367175218,"node_id":"MDU6SXNzdWUzNjcxNzUyMTg=","number":106,"title":"Suggestions for more idiomatic code","user":{"login":"anjmao","id":3028012,"node_id":"MDQ6VXNlcjMwMjgwMTI=","avatar_url":"https://avatars0.githubusercontent.com/u/3028012?v=4","gravatar_id":"","url":"https://api.github.com/users/anjmao","html_url":"https://github.com/anjmao","followers_url":"https://api.github.com/users/anjmao/followers","following_url":"https://api.github.com/users/anjmao/following{/other_user}","gists_url":"https://api.github.com/users/anjmao/gists{/gist_id}","starred_url":"https://api.github.com/users/anjmao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anjmao/subscriptions","organizations_url":"https://api.github.com/users/anjmao/orgs","repos_url":"https://api.github.com/users/anjmao/repos","events_url":"https://api.github.com/users/anjmao/events{/privacy}","received_events_url":"https://api.github.com/users/anjmao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-10-05T11:43:21Z","updated_at":"2018-10-08T12:51:20Z","closed_at":null,"author_association":"COLLABORATOR","body":"Hi,\r\n\r\n1. Current api could be improved a bit. Example from current generated soap client.\r\n\r\n```go\r\nfunc NewSOAPClient(url string, insecureSkipVerify bool, auth *BasicAuth) *SOAPClient {\r\n\ttlsCfg := &tls.Config{\r\n\t\tInsecureSkipVerify: insecureSkipVerify,\r\n\t}\r\n\treturn NewSOAPClientWithTLSConfig(url, tlsCfg, auth)\r\n}\r\n\r\nfunc NewSOAPClientWithTLSConfig(url string, tlsCfg *tls.Config, auth *BasicAuth) *SOAPClient {\r\n\treturn &SOAPClient{\r\n\t\turl:    url,\r\n\t\ttlsCfg: tlsCfg,\r\n\t\tauth:   auth,\r\n\t}\r\n}\r\n```\r\n\r\nThis is not very friendly api to use. Instead it's a common practice in go to use ...option. These 2 functions which are both not flexible can be refactored to\r\n\r\n```go\r\nfunc NewSOAPClient(opt ...SOAPOption) *SOAPClient {\r\n\topts := defaultSOAPOptions\r\n\tfor _, o := range opt {\r\n\t\to(&opts)\r\n\t}\r\n        return &SOAPClient{\r\n\t\turl:    opts.url,\r\n\t\ttlsCfg: opts.tlsCfg,\r\n\t\tauth:   opts.auth,\r\n\t}\r\n}\r\n```\r\n\r\nUsage\r\n\r\n```go\r\nclient := NewSOAPClient(\r\n       gowsdl.URL('myservice.asmx'), \r\n       gowsdl.TLSCfg(....),\r\n       gowsdl.Auth(...),\r\n       gowsdl.SothingElse(...)\r\n)\r\n```\r\nIt will also allow to stay backwards compatible add be able to add new config options in the feature.\r\n\r\n2. It's not possible to set global request headers, for example there is hardcoded `req.Header.Set(\"User-Agent\", \"gowsdl/0.1\")`, but service which I want to call checks if user-agent is `name-x` otherwise to throws unauthorised fault error.\r\nThis can be implemented simply by having `SOAPOption` RequestHeaders.\r\n\r\n3. There are log.Println statments inside code https://github.com/hooklift/gowsdl/blob/master/soap_tmpl.go#L268. This is bad when using docker and kubernetes. For example in my services all stdout logs a automatically pushed elastic search(kibana). In general print statements should be used only on some tracing mode enabled."},"comment":{"url":"https://api.github.com/repos/hooklift/gowsdl/issues/comments/427820125","html_url":"https://github.com/hooklift/gowsdl/issues/106#issuecomment-427820125","issue_url":"https://api.github.com/repos/hooklift/gowsdl/issues/106","id":427820125,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzgyMDEyNQ==","user":{"login":"anjmao","id":3028012,"node_id":"MDQ6VXNlcjMwMjgwMTI=","avatar_url":"https://avatars0.githubusercontent.com/u/3028012?v=4","gravatar_id":"","url":"https://api.github.com/users/anjmao","html_url":"https://github.com/anjmao","followers_url":"https://api.github.com/users/anjmao/followers","following_url":"https://api.github.com/users/anjmao/following{/other_user}","gists_url":"https://api.github.com/users/anjmao/gists{/gist_id}","starred_url":"https://api.github.com/users/anjmao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anjmao/subscriptions","organizations_url":"https://api.github.com/users/anjmao/orgs","repos_url":"https://api.github.com/users/anjmao/repos","events_url":"https://api.github.com/users/anjmao/events{/privacy}","received_events_url":"https://api.github.com/users/anjmao/received_events","type":"User","site_admin":false},"created_at":"2018-10-08T12:51:20Z","updated_at":"2018-10-08T12:51:20Z","author_association":"COLLABORATOR","body":"@c4milo I Agree for modules. I'm currently testing library with my changes by calling some of our production soap services, but I'm getting XML marshal/unmarshal errors. I added comment in my PR."}}
{"actor":{"display_login":"anjmao"}}