Skip to content

Instantly share code, notes, and snippets.

@gerep
Created April 12, 2016 23:57
Show Gist options
  • Select an option

  • Save gerep/0b1ec10278ac9bc28e279db771c3e4b7 to your computer and use it in GitHub Desktop.

Select an option

Save gerep/0b1ec10278ac9bc28e279db771c3e4b7 to your computer and use it in GitHub Desktop.
package main
import "fmt"
// The dumb way to deal with SOAP requests
func userRequest(userId string) string {
template := soapify(userTemplate)
return fmt.Sprintf(template, userId)
}
func soapify(template string) string {
return fmt.Sprintf(userTemplate, template)
}
const soapTemplate =
`<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://we&#x2764;namespaces.com/">
<soapenv:Header/>
<soapenv:Body>
%s
</soapenv:Body>
</soapenv:Envelope>`
const userTemplate =
`<github:user>
<arg0>%s</arg0>
</github:user>`
func main() {
payload := userRequest("dmichael")
fmt.Println(payload)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment