Пример #1
0
func main() {
	flag.Parse()
	api, err := ramlapi.ProcessRAML(ramlFile)
	if err != nil {
		log.Fatal(err)
	}
	log.Println("Processing API spec for", ramlFile)
	generate(api, genFile)
	log.Println("Created handlers in ", genFile)
}
Пример #2
0
func assembleRoutes(r *mux.Router, f string) {
	// Parse the RAML API specification.
	api, err := ramlapi.ProcessRAML(f)
	if err != nil {
		log.Fatal(err)
	}
	logChannel("raml-processor", fmt.Sprintf("processing API spec for %s", api.Title))
	logChannel("raml-processor", fmt.Sprintf("base URI at %s", api.BaseUri))
	ramlapi.Build(api, routerFunc)
}
Пример #3
0
func assembleRoutes() {
	var err error

	// If bundling is enabled, read the RAML
	// from bundle.go
	if os.Getenv("BUNDLE_ASSETS") == "1" {
		ramlFile := os.Getenv("RAMLFILE_NAME")

		if ramlFile == "" {
			ramlFile = "api.raml"
		}

		bundle, err := CardBundle.Open(ramlFile)
		if err != nil {
			log.Fatal(err)
		}
		data, err := ioutil.ReadAll(bundle)
		if err != nil {
			log.Fatal(err)
		}
		err = yaml.Unmarshal(data, &api)
		if err != nil {
			log.Fatal(err)
		}
		// Otherwise, read the file from the filesystem.
	} else {
		ramlPath := os.Getenv("RAMLFILE_PATH")

		if ramlPath == "" {
			ramlPath = "api.raml"
		}

		api, err = ramlapi.ProcessRAML(ramlPath)
		if err != nil {
			log.Fatal(err)
		}
	}
	journal.LogChannel("raml-processor", fmt.Sprintf("processing API spec for %s", api.Title))
	journal.LogChannel("raml-processor", fmt.Sprintf("base URI at %s", api.BaseUri))
	ramlapi.Build(api, routerFunc)
}
Пример #4
0
func assembleRoutes(r *mux.Router, f string) {
	var err error
	// If bundling is enabled, read the RAML
	// from bundle.go
	if os.Getenv("BUNDLE_ASSETS") != "" {
		bundle, _ := MainBundle.Open("api.raml")
		data, _ := ioutil.ReadAll(bundle)
		err = yaml.Unmarshal(data, &api)
		if err != nil {
			log.Fatal(err)
		}
		// Otherwise, read the file from the filesystem.
	} else {
		api, err = ramlapi.ProcessRAML(f)
		if err != nil {
			log.Fatal(err)
		}
	}
	journal.LogChannel("raml-processor", fmt.Sprintf("processing API spec for %s", api.Title))
	journal.LogChannel("raml-processor", fmt.Sprintf("base URI at %s", api.BaseUri))
	ramlapi.Build(api, routerFunc)
}