Guest User

Untitled

a guest
Jun 22nd, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. package server
  2.  
  3. import "github.com/kimrgrey/go-create-react-app/webpack"
  4.  
  5. // User represents current user session
  6. type User struct {
  7. Email string
  8. FirstName string
  9. LastName string
  10. }
  11.  
  12. // ViewData contains data for the view
  13. type ViewData struct {
  14. CurrentUser User
  15. assetsMapper webpack.AssetsMapper
  16. }
  17.  
  18. // NewViewData creates new data for the view
  19. func NewViewData(buildPath string) (ViewData, error) {
  20. assetsMapper, err := webpack.NewAssetsMapper(buildPath)
  21. if err != nil {
  22. return ViewData{}, err
  23. }
  24.  
  25. return ViewData{
  26. CurrentUser: User{
  27. Email: "bill@example.com",
  28. FirstName: "Bill",
  29. LastName: "Black",
  30. },
  31. assetsMapper: assetsMapper,
  32. }, nil
  33. }
  34.  
  35. // Webpack maps file name to path
  36. func (d ViewData) Webpack(file string) string {
  37. return d.assetsMapper(file)
  38. }
Add Comment
Please, Sign In to add comment