英文:
Go as backend API, Polymer frontend
问题
我正在努力找出将Polymer与我的Go应用程序端点进行通信的最佳方法。我正在使用Go和Postgres作为后端,但希望使用Polymer作为前端,而不是Go的html/template包。有人对如何设置这个有好的建议吗?抱歉,我在这部分有些困惑。我看过Francesc Campoy的polymer-gopher视频,但他好像已经设置好了应用程序?
另外,你是否建议Go也处理路由,还是只作为这种设置的数据端点?
谢谢大家
英文:
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
答案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)
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论