~pkal/dirconf

d0405100a951e58acf9006049e3923031e15c0b8 — Philip K 2 years ago 9e3748a
added url parser
1 files changed, 17 insertions(+), 0 deletions(-)

A url.go
A url.go => url.go +17 -0
@@ 0,0 1,17 @@
package dirconf

import "net/url"

// URL returns an url.URL object from the current configuration
func (c *Conf) URL(key string) (*url.URL, error) {
	str, err := c.String(key)
	if err != nil {
		return nil, err
	}

	u, err := url.Parse(str)
	if err != nil {
		return nil, ErrWrongType
	}
	return u, nil
}