auth/options.go
func (opts *jwtOptions) Parse(optMap map[string]string) error {
	var err error
	if ttl := optMap[optTTL]; ttl != "" {
		opts.TTL, err = time.ParseDuration(ttl)
		if err != nil {
			return err
		}
	}

	if file := optMap[optPublicKey]; file != "" {
		opts.PublicKey, err = ioutil.ReadFile(file)
		if err != nil {
			return err
		}
	}

	if file := optMap[optPrivateKey]; file != "" {
		opts.PrivateKey, err = ioutil.ReadFile(file)
		if err != nil {
			return err
		}
	}

	// signing method is a required field
	method := optMap[optSignMethod]
	opts.SignMethod = jwt.GetSigningMethod(method)
	if opts.SignMethod == nil {
		return ErrInvalidAuthMethod
	}

	return nil
}
func (opts *jwtOptions) Parse(optMap map[string]string) error {
	var err error
	if ttl := optMap[optTTL]; ttl != "" {
		opts.TTL, err = time.ParseDuration(ttl)
		if err != nil {
			return err
		}
	}

	if file := optMap[optPublicKey]; file != "" {
		opts.PublicKey, err = ioutil.ReadFile(file)
		if err != nil {
			return err
		}
	}

	if file := optMap[optPrivateKey]; file != "" {
		opts.PrivateKey, err = ioutil.ReadFile(file)
		if err != nil {
			return err
		}
	}

	// signing method is a required field
	method := optMap[optSignMethod]
	opts.SignMethod = jwt.GetSigningMethod(method)
	if opts.SignMethod == nil {
		return ErrInvalidAuthMethod
	}

	return nil
}
func ( opts * jwtOptions ) Parse ( optMap map [ string ] string ) error { var err error if ttl := optMap [ optTTL ] ; ttl != " " { opts . TTL , err = time . ParseDuration ( ttl ) if err != nil { return err } } if file := optMap [ optPublicKey ] ; file != " " { opts . PublicKey , err = ioutil . ReadFile ( file ) if err != nil { return err } } if file := optMap [ optPrivateKey ] ; file != " " { opts . PrivateKey , err = ioutil . ReadFile ( file ) if err != nil { return err } } // signing method is a required field method := optMap [ optSignMethod ] opts . SignMethod = jwt . GetSigningMethod ( method ) if opts . SignMethod == nil { return ErrInvalidAuthMethod } return nil }
// Parse will load options from the specified map
Parse will load options from the specified map