Created
March 1, 2016 16:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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