different approach to build REST APIs - swappable libs/frameworks

blov · · 548 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi</p> <p>TL;DR</p> <p>This is a project which should help you get things done faster. Here is documentation <a href="https://nildev.gitbooks.io/nildev/content/index.html" rel="nofollow">https://nildev.gitbooks.io/nildev/content/index.html</a>.</p> <p>Long story</p> <p>Whenever you start working on REST API first thing you do is you start from setting up whole infrastructure, wiring code like routing, middleware, configs and so on. Some devs like frameworks, some prefer libs, some go their own way and just does copy/paste from their template. But I believe that vast majority will agree that time you spent on these tasks feels like waste of time. That&#39;s one. </p> <p>Another challenge you get in to is &#34;which framework, library should I use for tasks mentioned above&#34;. I was going through reddit and forums and at least i got an impression that if there would be an option not to use any 3rd party framework, lib devs would do that. Using plain <code>net/http</code> is what a lot of us prefer. This applies to other packages as well. I think reason for that is that frameworks comes and goes, new emerges, old get&#39;s forgotten and we are left with challenges how to switch to new &#34;better&#34; ones. I thinks it&#39;s unfair. We should be able not to worry about this. </p> <p>So how nildev tries to solve it ? Well idea is that all infrastructure code should be &#34;swappable&#34;. Today I use &#34;Martini&#34; and tomorrow I want to change it to something else. My approach here is code generation and predefined &#34;flavoured&#34; API host containers (not docker container in this context). For example I have this <a href="https://github.com/nildev/api-host" rel="nofollow">https://github.com/nildev/api-host</a> container which uses gorilla libs. But if I would find more attractive lib I would create another one and then using nildev would generate glue code to merge my endpoint, which encapsulates logic, with this new container. <a href="https://github.com/nildev/auth" rel="nofollow">https://github.com/nildev/auth</a> is sample service build with nildev. </p> <p>Ideally the only code I want to write and worry about is the one that is specific to my endpoint. The rest should require as minimal time investment as possible.</p> <p>In this <a href="https://nildev.gitbooks.io/nildev/content/index.html" rel="nofollow">https://nildev.gitbooks.io/nildev/content/index.html</a> i&#39;ve tried to document my approach and explain how in current prototype it works. Here <a href="https://github.com/nildev" rel="nofollow">https://github.com/nildev</a> you can find sub projects.</p> <p>I used this for couple of my own small projects and was satisfied with it (what a surprise :)). But now I want to share it with others and get some opinions and well-argumented critique. Does this make any sense or it&#39;s total BS.</p> <p>Thanks!</p>

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

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