Exemplo n.º 1
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)
}
Exemplo n.º 2
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)
}
Exemplo n.º 3
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)
}