Execute Gin, Iris, Gorilla or whatever else on AWS Lambda seamlessly.

blov · · 781 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Before:</p> <pre><code>package main import ( &#34;net/http&#34; &#34;github.com/gin-gonic/gin&#34; ) var r *gin.Engine func handle(ctx *gin.Context) { ctx.String(http.StatusOK, &#34;Hello, %s!&#34;, ctx.Param(&#34;name&#34;)) } func init() { r = gin.Default() r.GET(&#34;/hello/:name&#34;, handle) } func main() { r.Run(&#34;:8080&#34;) } </code></pre> <p>After:</p> <pre><code>package main import ( &#34;net/http&#34; &#34;github.com/eawsy/aws-lambda-go-net/service/lambda/runtime/net&#34; &#34;github.com/gin-gonic/gin&#34; ) var r *gin.Engine func handle(ctx *gin.Context) { ctx.String(http.StatusOK, &#34;Hello, %s!&#34;, ctx.Param(&#34;name&#34;)) } func init() { r = gin.Default() r.GET(&#34;/hello/:name&#34;, handle) go http.Serve(net.Listener(), r) } func main() { } </code></pre> <p>Spot the difference :)</p> <p><a href="https://github.com/eawsy/aws-lambda-go-net" rel="nofollow">BTW</a> </p> <hr/>**评论:**<br/><br/>danilobuerger: <pre><p>Ugh, Iris.</p> <p><a href="https://www.reddit.com/r/golang/comments/57w79c/why_you_really_should_stop_using_iris/" rel="nofollow">https://www.reddit.com/r/golang/comments/57w79c/why_you_really_should_stop_using_iris/</a> <a href="https://www.reddit.com/r/golang/comments/57tmp1/why_you_should_not_use_iris_for_your_go_projects/" rel="nofollow">https://www.reddit.com/r/golang/comments/57tmp1/why_you_should_not_use_iris_for_your_go_projects/</a></p></pre>lsuss: <pre><p>The example is about Gin. But this post isn&#39;t about Iris or wathever, it&#39;s about a way to run <strong>any</strong> HTTP Golang web framework on AWS Lambda (which is awesome, you agree :p).</p></pre>hipone: <pre><p>The framework in question is mentioned in the title and put alongside other Go frameworks. The point here might be that this framework should not be considered &#34;equal&#34; to other frameworks, as there&#39;s some fishy history behind it.</p></pre>fsenart: <pre><p>Actually, it is equal to &#34;whatever else&#34; :) No seriously I understand the problem behind Iris but what I want to say through this post and the associated project is about how to migrate existing apps to AWS Lambda. Also, my goal was not to debate around the &#34;correctness&#34; or the &#34;behavior&#34; of a &#34;creepy&#34; open source developer. </p></pre>danilobuerger: <pre><p>Featuring him in the README will lead some people to consider it a good framework by association (same as some do, by the amount of stars he botted). That in turn, will lead to people (especially newcomers to the language) wasting time on it. There are enough good web frameworks out there that you could have used in the README instead to show of that it works with any.</p></pre>fsenart: <pre><p>Wait for it...</p> <p>Iris is no more in the README :)</p></pre>lsuss: <pre><p><a href="https://www.youtube.com/watch?v=NNAuJqV-n9g" rel="nofollow">https://www.youtube.com/watch?v=NNAuJqV-n9g</a></p></pre>youtubefactsbot: <pre><blockquote> <p><a href="http://youtu.be/NNAuJqV-n9g" rel="nofollow"><strong>Bomb has been defused - CS:GO Sound Effect [0:02]</strong></a></p> <p><a href="https://www.youtube.com/channel/UCQn7QtrjtLpMdSNLBf8iStg" rel="nofollow"><em><sup>Sound</sup> <sup>Effects</sup> <sup>&amp;</sup> <sup>Templates</sup></em></a> <sup>in</sup> <sup>Howto</sup> <sup>&amp;</sup> <sup>Style</sup></p> <p><em><sup>130,652</sup> <sup>views</sup> <sup>since</sup> <sup>Apr</sup> <sup>2015</sup></em></p> </blockquote> <p><a href="http://www.reddit.com/r/youtubefactsbot/wiki/index" rel="nofollow"><sup>bot</sup> <sup>info</sup></a></p></pre>danilobuerger: <pre><p>Nice!</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

781 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传