Skip to content

Instantly share code, notes, and snippets.

@eedrummer
Created March 1, 2016 16:30
Show Gist options
  • Save eedrummer/64791b7f75d3d21cae2d to your computer and use it in GitHub Desktop.
Save eedrummer/64791b7f75d3d21cae2d to your computer and use it in GitHub Desktop.
ecqm with static hosting and pulling the user from a header set by nginx
package main
import (
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/mitre/ecqm/controllers"
"gopkg.in/mgo.v2"
)
func main() {
e := echo.New()
session, err := mgo.Dial("localhost")
if err != nil {
panic(err)
}
db := session.DB("fhir")
e.Get("/QualityReport/:id", controllers.ShowQualityReportHandler(db))
e.Post("/QualityReport", controllers.CreateQualityReportHandler(db))
e.Get("/Measure/:id", controllers.ShowMeasureHandler(db))
e.Get("/Measure", controllers.IndexMeasureHandler(db))
staticPath := "/Users/andrewg/projects/ecqm-frontend/dist/"
e.Index(staticPath + "index.html")
e.Static("/assets", staticPath+"assets")
e.Use(middleware.Logger())
e.Use(userLogger)
e.Run(":3001")
}
func userLogger(c *echo.Context) error {
logger := c.Echo().Logger()
user := c.Request().Header.Get("X-USER")
logger.Println("User info: %s", user)
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment