示例#1
0
// generate security related code
func generateSecurity(schemes map[string]raml.SecurityScheme, dir string) error {
	var err error

	// generate oauth2 middleware
	for k, ss := range schemes {
		if ss.Type != security.Oauth2 { // only support oauth2 now
			continue
		}

		sd := security.New(&ss, k, "")

		pss := pythonSecurity{Security: &sd}
		err = pss.generate(dir)
		if err != nil {
			return err
		}
	}
	return nil
}
示例#2
0
func generateSecurity(schemes map[string]raml.SecurityScheme, dir, packageName string) error {
	var err error

	// generate oauth2 middleware
	for k, ss := range schemes {
		if ss.Type != security.Oauth2 {
			continue
		}

		sd := security.New(&ss, k, packageName)

		gss := goSecurity{Security: &sd}
		err = gss.generate(dir)

		if err != nil {
			log.Errorf("generateSecurity() failed to generate %v, err=%v", k, err)
			return err
		}
	}
	return nil
}