examples of well architected (clean code) rest api's without a framework

blov · · 583 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>hi I&#39;m just looking for a few examples on GitHub. found 1 to date. I like to check out a few more if theres any out there. just to compare them. thanks guys! heres the example I&#39;ve been looking at <a href="https://github.com/ManuelKiessling/go-cleanarchitecture">https://github.com/ManuelKiessling/go-cleanarchitecture</a></p> <hr/>**评论:**<br/><br/>neoasterisk: <pre><p>Just so you know, the package you found is more or less &#39;unclean&#39; architecture in the Go world. When you bring a pattern from other languages you need to apply it to the Go world.</p> <p>Here&#39;s some tips:</p> <ul> <li><a href="https://rakyll.org/style-packages/" rel="nofollow">https://rakyll.org/style-packages/</a></li> <li><a href="https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1#.el775uizc" rel="nofollow">https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1#.el775uizc</a></li> </ul> <p>If you want to translate the clean architecture pattern in Go, those will help.</p></pre>eoin_ahern: <pre><p>yeah, thats what I was thinking. that&#39;s why I was in search of a second opinion.</p> <blockquote> <p>other languages you need to apply it to the Go world.</p> </blockquote></pre>newbgopher: <pre><p>does the &#34;clean code architecture&#34; aka uncle bob pattern apply to Go also? im just curious to know what other solutions are out there.</p></pre>CaptaincCodeman: <pre><p>No reason why it can&#39;t. Here&#39;s my attempt at it:</p> <p><a href="https://github.com/CaptainCodeman/clean-go" rel="nofollow">https://github.com/CaptainCodeman/clean-go</a></p></pre>newbgopher: <pre><blockquote> <p><a href="https://github.com/CaptainCodeman/clean-go" rel="nofollow">https://github.com/CaptainCodeman/clean-go</a></p> </blockquote> <p>thanks for the sample repo!</p></pre>eoin_ahern: <pre><p>cheers! appreciate the link</p></pre>sh41: <pre><p>I don&#39;t know if this fits what you&#39;re looking for, but I&#39;m very happy with and proud of the architecture of my personal site [0], and you&#39;re welcome to look at it and compare. It errs on the side of being simple and pragmatic rather than overly general.</p> <p>I have plans for how to improve some of its parts, but for the most part, I&#39;m very happy with it, and it&#39;s very functional. Of course, I&#39;m always looking to improve and don&#39;t mind any constructive feedback.</p> <p>[0] <a href="https://github.com/shurcooL/home" rel="nofollow">https://github.com/shurcooL/home</a></p></pre>eoin_ahern: <pre><p>I&#39;m interested primarily in restful apis. The architecture would be slightly different I suppose because there is no view/UI layer. I presume you could replace the view with the routes with an Api. Im just not 100%. I guess the data and domain would remain relatively similar&gt; what you&#39;re looking for, but I&#39;m very happy with and proud of the architecture of my personal site [0],</p></pre>sh41: <pre><p>Fair enough.</p> <p>There is a somewhat RESTful API component, see <a href="https://github.com/shurcooL/home/search?q=api" rel="nofollow">https://github.com/shurcooL/home/search?q=api</a>. However, the underlying HTTP implementation is both temporary and an unimportant implementation details, because all my clients/consumers are using the Go client.</p> <p>I can update both the handler and client library at the same time, and while the HTTP API changes, all end consumers are unaffected.</p></pre>titpetric: <pre><p>I could point you to my books repo, for my <a href="https://leanpub.com/12fa-docker-golang" rel="nofollow">12 Factors of Go and Docker</a> book which I&#39;m currently writing:</p> <p><a href="https://github.com/titpetric/books/tree/master/12fa-docker-golang/chapter7" rel="nofollow">https://github.com/titpetric/books/tree/master/12fa-docker-golang/chapter7</a></p> <p>It conforms and provides approaches in line with the <a href="https://12factor.net" rel="nofollow">https://12factor.net</a> recommendations (listed in the readme). In terms of how I structure my APIs, I hope that I&#39;ve chosen some kind of loosely coupled package structure. As such, currently I can register/unregister API endpoints with one-line call in main.go - and can copy some standard API implementation between various projects (api/health.go for a &#34;portable&#34; API example). I&#39;m happy with it, but given a few refactoring sprints I suspect I could improve some things (mainly in regards to common/redis.go, functional options, etc.). I hope it helps, and I also welcome comments from Go gurus that might have a look at the code.</p> <p>Edit: linked the book which should in time provide a more broad viewpoint on 12 factor app development. It&#39;s already about 50 pages and growing.</p></pre>eoin_ahern: <pre><blockquote> <p>improve some things (mainly in regards to common/redis.go, functional options, etc.). I hope it helps, and I also welcome comments from Go gurus that might have a look at the code.</p> </blockquote> <p>cool. this is all really useful info. cheers bro!</p></pre>titpetric: <pre><p>Hope it helps. There are also some wonderful very minimal frameworks out there, I have <a href="https://github.com/pressly/chi" rel="nofollow">pressly/chi</a> bookmarked because it&#39;s using Go 1.7 contexts and might be better suited for more complex applications.</p></pre>eoin_ahern: <pre><p>never heard of 12factor.net. ill check it out.</p></pre>

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

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