Ejemplo n.º 1
1
func Init(e *echo.Echo) {
	const (
		indexPath    string = "public/views/index.html"
		faviconPath  string = "public/favicon.ico"
		templatePath string = "public/views"
		staticPath   string = "public/static"
	)

	e.Index(indexPath)
	e.Favicon(faviconPath)
	e.Static("/static", staticPath)

	initTemplate(e, templatePath)
}
Ejemplo n.º 2
0
// RegisterRoutes sets up the http request handlers with Echo
func RegisterRoutes(e *echo.Echo, db *mgo.Database, basePieURL string, service service.RiskService, fnDelayer *FunctionDelayer) {
	e.Get("/pies/:id", func(c *echo.Context) (err error) {
		pie := &plugin.Pie{}
		id := c.Param("id")
		if bson.IsObjectIdHex(id) {
			query := db.C("pies").FindId(bson.ObjectIdHex(id))
			err = query.One(pie)
			if err == nil {
				c.JSON(200, pie)
			}
		} else {
			c.String(400, "Bad ID format for requested Pie. Should be a BSON Id")
		}
		return
	})

	e.Post("/calculate", func(c *echo.Context) (err error) {
		patientID := c.Form("patientId")
		fhirEndpointURL := c.Form("fhirEndpointUrl")
		key := fmt.Sprintf("%s@%s", patientID, fhirEndpointURL)
		fnDelayer.Delay(key, func() {
			service.Calculate(patientID, fhirEndpointURL, basePieURL)
		})
		return
	})
}
Ejemplo n.º 3
0
// apiRoute contains router groups for API
func (a *App) apiRoute(e *echo.Echo) error {
	apiUrl, err := a.conf.Get("api-url")
	if err != nil {
		return err
	}
	//General API
	g := e.Group(apiUrl.(string))
	//auth
	g.Post("/auth", a.login)
	//oauth
	a.fb, err = oauth.NewFacebook(a)
	if err != nil {
		return err
	}
	fbg := g.Group("/oauth")
	fbg.Get("/facebook", a.facebookAuth)
	fbg.Get("/facebook/redirect", a.facebookRedirect)
	//tasks
	tokenizer := jwt.NewTokenizer(a)
	tg := g.Group("/tasks", tokenizer.Check())
	tg.Post("", a.create)
	tg.Get("/:id", a.retrieve)
	tg.Get("", a.retrieveAll)
	tg.Put("/:id", a.update)
	tg.Delete("/:id", a.delete)
	return nil
}
Ejemplo n.º 4
0
func SetupKeysRoutes(e *echo.Echo) {
	e.Get("", listKeys)
	e.Get("/:id", showKey)
	e.Post("", createKey)
	e.Put("/:id", updateKey)
	e.Delete("/:id", deleteKey)
}
Ejemplo n.º 5
0
func Init(e *echo.Echo) {
	e.Pre(middleware.RemoveTrailingSlash())

	static.Init(e)

	todoroutes.Init(e)
}
Ejemplo n.º 6
0
func InitRoutes(e *echo.Echo) {
	h := new(handler)
	e.Get("/json", h.json())
	e.Get("/db", h.db())
	e.Get("/queries/*", h.queries())
	e.Get("/fortunes", h.fortunes())
	e.Get("/updates/*", h.updates())
	e.Get("/plaintext", h.plaintext())
}
Ejemplo n.º 7
0
func Init(e *echo.Echo, Debug bool) {
	c := cors.New(cors.Options{
		AllowedOrigins:   []string{"*"},
		AllowedMethods:   []string{"GET", "POST", "DELETE", "PUT", "PATCH"},
		AllowCredentials: true,
		Debug:            Debug,
	})
	e.Use(standard.WrapMiddleware(c.Handler))
}
Ejemplo n.º 8
0
func registerClient(e *echo.Echo) {
	e.Get("/bundle.js", func(c *echo.Context) error {
		return c.File("../client/bundle.js", "", false)
	})

	e.Get("/", func(c *echo.Context) error {
		return c.File("../client/index.html", "", false)
	})
}
// Run ...
func Run(application *echo.Echo) {
	var address = fmt.Sprintf("%s:%d", WebHost, WebPort)
	log.Printf("starting webserver on %s", address)
	if UseSSL {
		application.RunTLS(address, CertFile, KeyFile)
	} else {
		application.Run(address)
	}
}
Ejemplo n.º 10
0
func registerRouterHandler(e *echo.Echo) {
	a := e.Group("/admin")
	a.Get("/:id", func(c *echo.Context) error {
		return c.String(http.StatusOK, "/admin/"+c.Param("id"))
	})
	a.Get("/users/:name", func(c *echo.Context) error {
		return c.String(http.StatusOK, c.Param("name"))
	})
	a.Post("/login", login)
}
Ejemplo n.º 11
0
func Set(e *echo.Echo) *echo.Echo {

	e.Favicon("static/favicon.ico")
	e.Static("/", "static")

	e.Get("/", controller.Index)
	e.Get("/eval/", controller.Eval)
	e.Post("/eval/", controller.PostEval)

	return e
}
Ejemplo n.º 12
0
func serveStatic(e *echo.Echo) {
	for prefix, rootConf := range staticFileMap {
		filterPrefixs = append(filterPrefixs, prefix)

		if rootConf.isFile {
			e.File(prefix, ROOT+rootConf.root)
		} else {
			e.Static(prefix, ROOT+rootConf.root)
		}
	}
}
Ejemplo n.º 13
0
// Configure setups routes and templates
func Configure(r *render.BufferedRender, e *echo.Echo) error {
	// Add templates
	err := r.Load("500", utils.TmplAbs("500.tmpl"), utils.TmplAbs("layouts", "black_base.tmpl"))
	if err != nil {
		return err
	}

	e.SetHTTPErrorHandler(HandleError)
	e.Get("/500", FailOnPropouse)

	// Add routes
	return nil
}
Ejemplo n.º 14
0
func SetRouting(e *echo.Echo) {
	log.Info("Start set api's routing")
	g := e.Group("/api")

	// Members
	g.Get("/members", GetAllMembers())
	g.Get("/members/:id", GetMember())
	g.Post("/members", CreateMember())

	// Iterations
	g.Get("/iterations", GetAllIterations())
	g.Get("/iterations/:id/tasks", GetIterationTasks())
	g.Post("/iterations", CreateIteration())

	// Task
	g.Post("/tasks", CreateTask())
}
Ejemplo n.º 15
0
Archivo: theme.go Proyecto: mewben/onix
// Setup theme
func Setup(e *echo.Echo, mode string) {
	var t Template
	if mode == "dev" {
		// development
		t.templates = template.Must(template.ParseGlob("internals/themes/" + Theme + "/*.html"))

		e.Static("/assets", "internals/themes/"+Theme+"/assets")
		e.File("/favicon.ico", "internals/themes/"+Theme+"favicon.ico")
	} else {
		// production
		t.templates = template.Must(template.ParseGlob("public/themes/" + Theme + "/*.html"))

		e.Static("/assets", "public/themes/"+Theme+"/assets")
		e.File("/favicon.ico", "public/themes/"+Theme+"favicon.ico")
	}

	e.SetRenderer(&t)
}
Ejemplo n.º 16
0
func registerRouterHandler(e *echo.Echo) {
	e.Get("/users/:id", func(c *echo.Context) error {
		return c.String(http.StatusOK, "/users/"+c.Param("id"))
	})
	e.Get("/:id", func(c *echo.Context) error {
		return c.String(http.StatusOK, "/"+c.Param("id"))
	})
	e.Get("/post/:id", func(c *echo.Context) error {
		return c.String(http.StatusOK, getPost(c.Param("id")))
	})
	e.Get("/welcome", welcome)
}
Ejemplo n.º 17
0
func RegisterController(name string, e *echo.Echo, m []echo.Middleware, dal DataAccessLayer, config Config) {
	rc := NewResourceController(name, dal)
	rcBase := e.Group("/" + name)
	rcBase.Get("", rc.IndexHandler)
	rcBase.Post("", rc.CreateHandler)
	rcBase.Delete("", rc.ConditionalDeleteHandler)

	rcItem := rcBase.Group("/:id")
	rcItem.Get("", rc.ShowHandler)
	rcItem.Put("", rc.UpdateHandler)
	rcItem.Delete("", rc.DeleteHandler)

	if len(m) > 0 {
		rcBase.Use(m...)
	}

	if config.UseSmartAuth {
		rcBase.Use(SmartAuthHandler(name))
	}
}
Ejemplo n.º 18
0
//	注册路由
func registerRoute(e *echo.Echo) {

	e.Get("/", welcome)
	e.Favicon("favicon.ico")

	e.Get("/:market/:code/:start/:end/1m", queryPeroid60)
}
Ejemplo n.º 19
0
func InitializeRenderers(e *echo.Echo) error {
	//e.Use(middleware.Logger())
	e.Use(middleware.Recover())
	e.SetRenderer(&EchoRenderer{})

	e.GET("/static*", RenderStatic)

	return nil
}
Ejemplo n.º 20
0
// Configure setups routes and templates
func Configure(r *render.BufferedRender, e *echo.Echo) error {
	// Add templates
	err := r.Load("legal_document", utils.TmplAbs("legal_document.tmpl"), utils.TmplAbs("layouts", "black_base.tmpl"))
	if err != nil {
		return err
	}

	// Add routes
	e.Get("/legal/licenses/:slug", Licenses)
	e.Get("/legal/terms-of-uses/:slug", UseTerms)
	e.Get("/legal/privacy-policies/:slug", PrivacyPolicies)
	return nil
}
Ejemplo n.º 21
0
// Configure setups routes and templates
func Configure(r *render.BufferedRender, e *echo.Echo) error {
	// Add templates
	err := r.Load("index", utils.TmplAbs("index.tmpl"), utils.TmplAbs("layouts", "blog.tmpl"))
	if err != nil {
		return err
	}

	err = r.Load("post", utils.TmplAbs("post.tmpl"), utils.TmplAbs("layouts", "blog.tmpl"))
	if err != nil {
		return err
	}

	err = r.Load("archive", utils.TmplAbs("archive.tmpl"), utils.TmplAbs("layouts", "blog.tmpl"))
	if err != nil {
		return err
	}

	err = r.Load("category", utils.TmplAbs("category.tmpl"), utils.TmplAbs("layouts", "blog.tmpl"))
	if err != nil {
		return err
	}

	err = r.Load("profile", utils.TmplAbs("profile.tmpl"), utils.TmplAbs("layouts", "red_base.tmpl"))
	if err != nil {
		return err
	}

	err = r.Load("contact", utils.TmplAbs("contact.tmpl"), utils.TmplAbs("layouts", "blog.tmpl"))
	if err != nil {
		return err
	}

	// Add routes
	e.Get("/", Index)
	e.Get("/posts/:id", PostView)
	e.Get("/categories/:id", CategoryView)
	e.Get("/archive/:id", ArchiveView)
	e.Get("/profiles/:id", ProfileView)
	e.Post("/posts/:id/comments", AddComment)
	e.Get("/contact", ContactView)
	e.Post("/contact", DoContact)
	return nil
}
Ejemplo n.º 22
0
func RegisterRoutes(e *echo.Echo, config map[string][]echo.Middleware, dal DataAccessLayer, serverConfig Config) {

	// Batch Support
	batch := NewBatchController(dal)
	e.Post("/", batch.Post)

	// Resources

	RegisterController("Appointment", e, config["Appointment"], dal, serverConfig)
	RegisterController("ReferralRequest", e, config["ReferralRequest"], dal, serverConfig)
	RegisterController("Account", e, config["Account"], dal, serverConfig)
	RegisterController("Provenance", e, config["Provenance"], dal, serverConfig)
	RegisterController("Questionnaire", e, config["Questionnaire"], dal, serverConfig)
	RegisterController("ExplanationOfBenefit", e, config["ExplanationOfBenefit"], dal, serverConfig)
	RegisterController("DocumentManifest", e, config["DocumentManifest"], dal, serverConfig)
	RegisterController("Specimen", e, config["Specimen"], dal, serverConfig)
	RegisterController("AllergyIntolerance", e, config["AllergyIntolerance"], dal, serverConfig)
	RegisterController("CarePlan", e, config["CarePlan"], dal, serverConfig)
	RegisterController("Goal", e, config["Goal"], dal, serverConfig)
	RegisterController("StructureDefinition", e, config["StructureDefinition"], dal, serverConfig)
	RegisterController("EnrollmentRequest", e, config["EnrollmentRequest"], dal, serverConfig)
	RegisterController("EpisodeOfCare", e, config["EpisodeOfCare"], dal, serverConfig)
	RegisterController("OperationOutcome", e, config["OperationOutcome"], dal, serverConfig)
	RegisterController("Medication", e, config["Medication"], dal, serverConfig)
	RegisterController("Procedure", e, config["Procedure"], dal, serverConfig)
	RegisterController("List", e, config["List"], dal, serverConfig)
	RegisterController("ConceptMap", e, config["ConceptMap"], dal, serverConfig)
	RegisterController("Subscription", e, config["Subscription"], dal, serverConfig)
	RegisterController("ValueSet", e, config["ValueSet"], dal, serverConfig)
	RegisterController("OperationDefinition", e, config["OperationDefinition"], dal, serverConfig)
	RegisterController("DocumentReference", e, config["DocumentReference"], dal, serverConfig)
	RegisterController("Order", e, config["Order"], dal, serverConfig)
	RegisterController("Immunization", e, config["Immunization"], dal, serverConfig)
	RegisterController("Device", e, config["Device"], dal, serverConfig)
	RegisterController("VisionPrescription", e, config["VisionPrescription"], dal, serverConfig)
	RegisterController("Media", e, config["Media"], dal, serverConfig)
	RegisterController("Conformance", e, config["Conformance"], dal, serverConfig)
	RegisterController("ProcedureRequest", e, config["ProcedureRequest"], dal, serverConfig)
	RegisterController("EligibilityResponse", e, config["EligibilityResponse"], dal, serverConfig)
	RegisterController("DeviceUseRequest", e, config["DeviceUseRequest"], dal, serverConfig)
	RegisterController("DeviceMetric", e, config["DeviceMetric"], dal, serverConfig)
	RegisterController("Flag", e, config["Flag"], dal, serverConfig)
	RegisterController("RelatedPerson", e, config["RelatedPerson"], dal, serverConfig)
	RegisterController("SupplyRequest", e, config["SupplyRequest"], dal, serverConfig)
	RegisterController("Practitioner", e, config["Practitioner"], dal, serverConfig)
	RegisterController("AppointmentResponse", e, config["AppointmentResponse"], dal, serverConfig)
	RegisterController("Observation", e, config["Observation"], dal, serverConfig)
	RegisterController("MedicationAdministration", e, config["MedicationAdministration"], dal, serverConfig)
	RegisterController("Slot", e, config["Slot"], dal, serverConfig)
	RegisterController("EnrollmentResponse", e, config["EnrollmentResponse"], dal, serverConfig)
	RegisterController("Binary", e, config["Binary"], dal, serverConfig)
	RegisterController("MedicationStatement", e, config["MedicationStatement"], dal, serverConfig)
	RegisterController("Person", e, config["Person"], dal, serverConfig)
	RegisterController("Contract", e, config["Contract"], dal, serverConfig)
	RegisterController("CommunicationRequest", e, config["CommunicationRequest"], dal, serverConfig)
	RegisterController("RiskAssessment", e, config["RiskAssessment"], dal, serverConfig)
	RegisterController("TestScript", e, config["TestScript"], dal, serverConfig)
	RegisterController("Basic", e, config["Basic"], dal, serverConfig)
	RegisterController("Group", e, config["Group"], dal, serverConfig)
	RegisterController("PaymentNotice", e, config["PaymentNotice"], dal, serverConfig)
	RegisterController("Organization", e, config["Organization"], dal, serverConfig)
	RegisterController("ImplementationGuide", e, config["ImplementationGuide"], dal, serverConfig)
	RegisterController("ClaimResponse", e, config["ClaimResponse"], dal, serverConfig)
	RegisterController("EligibilityRequest", e, config["EligibilityRequest"], dal, serverConfig)
	RegisterController("ProcessRequest", e, config["ProcessRequest"], dal, serverConfig)
	RegisterController("MedicationDispense", e, config["MedicationDispense"], dal, serverConfig)
	RegisterController("DiagnosticReport", e, config["DiagnosticReport"], dal, serverConfig)
	RegisterController("ImagingStudy", e, config["ImagingStudy"], dal, serverConfig)
	RegisterController("ImagingObjectSelection", e, config["ImagingObjectSelection"], dal, serverConfig)
	RegisterController("HealthcareService", e, config["HealthcareService"], dal, serverConfig)
	RegisterController("DataElement", e, config["DataElement"], dal, serverConfig)
	RegisterController("DeviceComponent", e, config["DeviceComponent"], dal, serverConfig)
	RegisterController("FamilyMemberHistory", e, config["FamilyMemberHistory"], dal, serverConfig)
	RegisterController("NutritionOrder", e, config["NutritionOrder"], dal, serverConfig)
	RegisterController("Encounter", e, config["Encounter"], dal, serverConfig)
	RegisterController("Substance", e, config["Substance"], dal, serverConfig)
	RegisterController("AuditEvent", e, config["AuditEvent"], dal, serverConfig)
	RegisterController("MedicationOrder", e, config["MedicationOrder"], dal, serverConfig)
	RegisterController("SearchParameter", e, config["SearchParameter"], dal, serverConfig)
	RegisterController("PaymentReconciliation", e, config["PaymentReconciliation"], dal, serverConfig)
	RegisterController("Communication", e, config["Communication"], dal, serverConfig)
	RegisterController("Condition", e, config["Condition"], dal, serverConfig)
	RegisterController("Composition", e, config["Composition"], dal, serverConfig)
	RegisterController("DetectedIssue", e, config["DetectedIssue"], dal, serverConfig)
	RegisterController("Bundle", e, config["Bundle"], dal, serverConfig)
	RegisterController("DiagnosticOrder", e, config["DiagnosticOrder"], dal, serverConfig)
	RegisterController("Patient", e, config["Patient"], dal, serverConfig)
	RegisterController("OrderResponse", e, config["OrderResponse"], dal, serverConfig)
	RegisterController("Coverage", e, config["Coverage"], dal, serverConfig)
	RegisterController("QuestionnaireResponse", e, config["QuestionnaireResponse"], dal, serverConfig)
	RegisterController("DeviceUseStatement", e, config["DeviceUseStatement"], dal, serverConfig)
	RegisterController("ProcessResponse", e, config["ProcessResponse"], dal, serverConfig)
	RegisterController("NamingSystem", e, config["NamingSystem"], dal, serverConfig)
	RegisterController("Schedule", e, config["Schedule"], dal, serverConfig)
	RegisterController("SupplyDelivery", e, config["SupplyDelivery"], dal, serverConfig)
	RegisterController("ClinicalImpression", e, config["ClinicalImpression"], dal, serverConfig)
	RegisterController("MessageHeader", e, config["MessageHeader"], dal, serverConfig)
	RegisterController("Claim", e, config["Claim"], dal, serverConfig)
	RegisterController("ImmunizationRecommendation", e, config["ImmunizationRecommendation"], dal, serverConfig)
	RegisterController("Location", e, config["Location"], dal, serverConfig)
	RegisterController("BodySite", e, config["BodySite"], dal, serverConfig)
}
Ejemplo n.º 23
0
func Set(e *echo.Echo, routes []string) *echo.Echo {
	e.SetRenderer(templates("view", routes))

	return e
}
Ejemplo n.º 24
0
func createDocsRoute(e *echo.Echo) {
	for apiKey, _ := range apiDescriptionsJson {
		e.Get("/docs/"+apiKey, apiDescriptionHandler)
	}
}
func SetupDropletActionsRoutes(e *echo.Echo) {
	e.Get("/:actionId", getDropletAction)
	e.Post("/disable_backups", disableDropletBackups)
	e.Post("/reboot", rebootDroplet)
	e.Post("/power", powerCycleDroplet)
	e.Post("/shutdown", shutdownDroplet)
	e.Post("/power_off", powerOffDroplet)
	e.Post("/power_on", powerOnDroplet)
	e.Post("/restore", restoreDroplet)
	e.Post("/password_reset", passwordResetDroplet)
	e.Post("/resize", resizeDroplet)
	e.Post("/rebuild", rebuildDroplet)
	e.Post("/rename", renameDroplet)
	e.Post("/change_kernel", changeDropletKernel)
	e.Post("/enable_ipv6", enableDropletIPv6)
	e.Post("/enable_private_networking", enableDropletPrivateNetworking)
	e.Post("/snapshot", snapshotDroplet)
	e.Post("/upgrade", upgradeDroplet)
}
Ejemplo n.º 26
0
func Wrap(e *echo.Echo) {
	e.Get("/debug/pprof/", IndexHandler)
	e.Get("/debug/pprof/heap", HeapHandler)
	e.Get("/debug/pprof/goroutine", GoroutineHandler)
	e.Get("/debug/pprof/block", BlockHandler)
	e.Get("/debug/pprof/threadcreate", ThreadCreateHandler)
	e.Get("/debug/pprof/cmdline", CmdlineHandler)
	e.Get("/debug/pprof/profile", ProfileHandler)
	e.Get("/debug/pprof/symbol", SymbolHandler)
}
Ejemplo n.º 27
0
// Setup routes for droplet actions
func SetupDropletsRoutes(e *echo.Echo) {
	e.Get("", listDroplets)
	e.Get("/:id", showDroplet)
	e.Post("", createDroplet)
	e.Delete("/:id", deleteDroplet)
	e.Get("/:id/kernels", listDropletKernels)
	e.Get("/:id/snapshots", listDropletSnapshots)
	e.Get("/:id/backups", listDropletBackups)
	e.Get("/:id/actions", listDropletActions)
	e.Get("/:id/neighbors", listDropletNeighbors)
}
Ejemplo n.º 28
0
func loadHandlers(e *echo.Echo) {

	if itrak.Debug {
		e.SetDebug(true)
	}

	// Point to the client application generated inside the webapp dir
	e.Index("./webapp/build/index.html")
	e.ServeDir("/", "./webapp/build/")

	server_stats = stats.New()
	e.Use(server_stats.Handler)

	e.Get("/stats", getStats)
	e.Get("/test1", getTestData)
	e.Get("/part", getPartsList)
	e.Get("/task", getTaskList)
	e.Get("/jtask", getJTaskList)

	e.Post("/login", login)
	e.Delete("/login", logout)

	e.Get("/people", getPeople)
	e.Get("/people/:id", getPerson)
	e.Post("/people/:id", savePerson)

	e.Get("/site", getSites)
	e.Get("/site/:id", getSite)
	e.Post("/site/:id", saveSite)

	e.Get("/roles", getRoles)

	e.Get("/vendors", getAllVendors)
	e.Post("/vendors/:id", saveVendor)

	// Equipment Related functions
	e.Get("/equipment", getAllEquipment)
	e.Get("/site_equipment/:id", getAllSiteEquipment)
	e.Get("/equipment/:id", getEquipment)
	e.Post("/equipment/:id", saveEquipment)
	e.Get("/subparts/:id", subParts)
	e.Get("/spares", getAllSpares)
	e.Get("/spares/:id", getEquipment)
	e.Post("/spares/:id", saveEquipment)
	e.Get("/consumables", getAllConsumables)
	e.Get("/consumables/:id", getEquipment)
	e.Post("/consumables/:id", saveEquipment)

	e.Get("/equiptype", getAllEquipTypes)
	e.Get("/equiptype/:id", getEquipType)
	e.Post("/equiptype/:id", saveEquipType)

	e.Get("/task", getAllTask)
	e.Get("/sitetask/:id", getSiteTasks)
	e.Get("/task/:id", getTask)
	e.Post("/task/:id", saveTask)
}
Ejemplo n.º 29
-1
Archivo: server.go Proyecto: xtfly/gofd
// OnStart ...
func (s *Server) OnStart(c *common.Config, e *echo.Echo) error {
	go func() { s.sessionMgnt.Start() }()

	e.Use(middleware.BasicAuth(s.Auth))
	e.POST("/api/v1/server/tasks", s.CreateTask)
	e.DELETE("/api/v1/server/tasks/:id", s.CancelTask)
	e.GET("/api/v1/server/tasks/:id", s.QueryTask)
	e.POST("/api/v1/server/tasks/status", s.ReportTask)

	return nil
}
Ejemplo n.º 30
-2
func Init(e *echo.Echo) {
	e.Use(middleware.Static("node_modules"))

	if env := os.Getenv("GO_ENV"); env == "" {
		e.Use(middleware.Static("client/dev"))
	} else {
		e.Use(middleware.Static("client/dist"))
	}
}