使用Go作为后端API,Polymer作为前端。

huangapple go评论83阅读模式
英文:

Go as backend API, Polymer frontend

问题

我正在努力找出将Polymer与我的Go应用程序端点进行通信的最佳方法。我正在使用Go和Postgres作为后端,但希望使用Polymer作为前端,而不是Go的html/template包。有人对如何设置这个有好的建议吗?抱歉,我在这部分有些困惑。我看过Francesc Campoy的polymer-gopher视频,但他好像已经设置好了应用程序?

另外,你是否建议Go也处理路由,还是只作为这种设置的数据端点?

谢谢大家 使用Go作为后端API,Polymer作为前端。

英文:

I'm trying to work out the best way of getting Polymer to talk to my go app end points? I'm using Go and Postgres as the backend, but would like to use Polymer as the front-end instead of the Go html/template package. Has anyone got a good suggestion on how is set this up? Sorry, struggling to get the penny dropping on this part. I've watched Francesc Campoy's polymer-gopher video but it looks like he has the app setup already?

Also, would you recommend having go handle the routing also, or just be the data end point for this type of setup?

Thanks guys and gals 使用Go作为后端API,Polymer作为前端。

答案1

得分: 5

你可能想要创建一个单页应用程序(从此链接中获取的图片):

  • Go - 后端(API)
  • HTML/JavaScript(Polymer)- 前端(静态内容)

在这种情况下,你不需要使用 Go 的 html/template,基本上你只需要创建一个 API,大多数情况下会返回 JSON。

你遵循这种方法的主要问题可能是如何保护后端端点的安全性,而不是处理解析模板,有一些选项可以解决这个问题,其中之一是 JSON 令牌。

英文:

Probably you want to create a single-page application (img taken from this link):

  • Go - backend (API)
  • HTML/javascript (polymer) - frontend (static content)

使用Go作为后端API,Polymer作为前端。

In this scenario you don't need to use go html/template, basically you just create an API that in most cases will be returning json.

Your main concern by following this approach could be about how to secure your backend endpoints rather than need to deal with parsing templates, there are some options for this, json tokens is one of them.

huangapple
  • 本文由 发表于 2017年2月19日 10:04:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/42322870.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定