8000 GitHub - percivalalb/sipuri: SIP URI Parser
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

percivalalb/sipuri

Repository files navigation

SIP URI Parser

CircleCI PkgGoDev

This module is a pure Golang implementation to parse URIs with the scheme sip: & sips:. It tries to adhere to the spec in RFC-3261 19.1.1. It is meant to be small and efficent and require no libraries outside the standard lib.

Requires go 1.18+

go get github.com/percivalalb/sipuri

Example

package main

import (
	"fmt"

	"github.com/percivalalb/sipuri"
)

func main() {
	// Parse the URI. Errors on unexpected schemes or malformed URIs
  	sipURI, err := sipuri.Parse("sip:user:password@host:port;uri-parameters?headers")
	if err != nil {
		panic(err)
	}

	// Print the consistent components
   	fmt.Println(sipURI.User()) // user
   	fmt.Println(sipURI.Password()) // password
    	fmt.Println(sipURI.Host()) // host:port
    	fmt.Printf("%v\n", sipURI.Params())  // map[uri-parameters:[]]
    	fmt.Printf("%v\n", sipURI.Headers()) // map[headers:[]]

	// Re-construct the URI
	fmt.Println(sipURI.String()) // sip:user:password@host:port;uri-parameters=?headers=
}

Disclaimer

The module should parse common sip: & sips: URIs, thought the module has yet to be thoroughly tested against outliers. Please report any issues, thanks!

About

SIP URI Parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0