routes

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SetupServer = func(appPort string) {
	var router = mux.NewRouter()

	router.Use(h.AddXRequestIdHandler, h.LogHttpRequestHandler, h.TokenAuthenticationHandler)

	router.HandleFunc("/ping", controllers.Ping).Methods("GET")
	router.HandleFunc("/env", controllers.GetEnvVars).Methods("GET")
	router.HandleFunc("/env", controllers.SetEnvVars).Methods("POST")
	router.HandleFunc("/env", controllers.DeleteVirtualEnvVars).Methods("DELETE")
	router.HandleFunc("/env/{name}", controllers.GetEnvVar).Methods("GET")
	router.HandleFunc("/about", controllers.About).Methods("GET")
	router.HandleFunc("/info", controllers.About).Methods("GET")
	router.HandleFunc("/file", controllers.GetFile).Methods("GET")
	router.HandleFunc("/file", controllers.PutFile).Methods("POST", "PUT")
	router.HandleFunc("/folder", controllers.GetFolder).Methods("GET")
	router.HandleFunc("/command", controllers.CommandPost).Methods("POST")
	router.HandleFunc("/commandyaml", controllers.CommandPostYaml).Methods("POST")
	router.HandleFunc("/commandparallel", controllers.CommandParallelPost).Methods("POST")
	router.HandleFunc("/commanddetached", controllers.CommandDetachedGet).Methods("GET")
	router.HandleFunc("/commanddetached", controllers.CommandDetachedDelete).Methods("DELETE")
	router.HandleFunc("/commanddetached/{cid}", controllers.CommandDetachedPost).Methods("POST")
	router.HandleFunc("/commanddetachedyaml/{cid}", controllers.CommandDetachedPostYaml).Methods("POST")
	router.HandleFunc("/commanddetached/{cid}", controllers.CommandDetachedGetById).Methods("GET")
	router.HandleFunc("/commanddetached/{cid}", controllers.CommandDetachedDeleteById).Methods("DELETE")
	router.HandleFunc("/processes", controllers.GetProcesses).Methods("GET")
	router.HandleFunc("/processes/{name}", controllers.GetProcessesByExecName).Methods("GET")

	fs := http.FileServer(http.Dir("./swaggerui/"))
	router.PathPrefix("/swaggerui/").Handler(http.StripPrefix("/swaggerui/", fs))

	ec := services.NewEurekaClient()
	ec.RegisterApp(environment.GetInstance().GetConfigEnvVars()[constants.APP_IP_PORT])

	u.CreateDir(constants.CMD_BACKGROUND_DIR)
	u.CreateDir(constants.CMD_BACKGROUND_STREAMS_DIR)

	var err error
	isSsl, _ := strconv.ParseBool(environment.GetInstance().GetConfigEnvVars()[constants.HTTPS_ENABLE])
	if isSsl == true {
		err = http.ListenAndServeTLS(":"+environment.GetInstance().GetConfigEnvVars()[constants.PORT],
			environment.GetInstance().GetConfigEnvVars()[constants.HTTPS_CERT],
			environment.GetInstance().GetConfigEnvVars()[constants.HTTPS_KEY],
			router)
	} else {
		err = http.ListenAndServe(":"+environment.GetInstance().GetConfigEnvVars()[constants.PORT], router)
	}

	if err != nil {
		fmt.Println(err)
	}
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL