Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.96 KB

README.md

File metadata and controls

61 lines (51 loc) · 1.96 KB

stravaganza

CI Status Go Report Card Coverage Godoc Releases LICENSE

Installation

go get -u github.com/jackal-xmpp/stravaganza

Example

package main

import (
	"fmt"
	"os"

	"github.com/jackal-xmpp/stravaganza"
)

func main() {
	iq, err := stravaganza.NewBuilder("iq").
		WithValidateJIDs(true).		
		WithAttribute("id", "zid615d9").
		WithAttribute("from", "ortuman@jackal.im/yard").
		WithAttribute("to", "noelia@jackal.im/balcony").
		WithAttribute("type", "get").
		WithChild(
			stravaganza.NewBuilder("ping").
				WithAttribute("xmlns", "urn:xmpp:ping").
				Build(),
		).
		BuildIQ()
	if err != nil {
		_, _ = fmt.Fprint(os.Stderr, err.Error())
		return
	}
	_ = iq.ToXML(os.Stdout, true)
}

Expected output:

<iq id='zid615d9' from='ortuman@jackal.im/yard' to='noelia@jackal.im/balcony' type='get'><ping xmlns='urn:xmpp:ping'/></iq>

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

License

Apache License 2.0