An amateur effort at creating a simple web framework.

polaris · · 496 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>It&#39;s only been a few months since I started working on Go. I have a microservice architecture for a web app I&#39;m developing, in the process, I ended up creating a very small framework (<em>with external dependencies</em>).</p> <p>I ran some basic benchmarking on it and didn&#39;t seem bad, I&#39;d like your opinion/feedback/advice to improve it.</p> <p>Here&#39;s the Github repo, <a href="https://github.com/bnkamalesh/webgo" rel="nofollow">WebGo</a>.</p> <hr/>**评论:**<br/><br/>Grundlebuttskin: <pre><p>It looks like you&#39;re missing a defer on the unlock within Context.copy. I like that you have CORS on here and an extensible middleware system. That means I could add logging, authentication, and all the other things I&#39;d need in a real app. I don&#39;t use mongo, and I&#39;m not sure I could hook this up to a different data store without modifying the framework itself. I also prefer goji&#39;s use of net/x/context because it&#39;s immutable and is what some other libraries, such as pat and appengine, use for request-scoped values. It looked like you&#39;re doing a bunch of unnecessary manual json decoding for the config; I&#39;m not sure why you didn&#39;t just use encoding/json.Unmarshal.</p></pre>kamaleshbn: <pre><blockquote> <p>It looks like you&#39;re missing a defer on the unlock within Context.copy</p> </blockquote> <p>I should have spent more time looking into the 3rd party libraries I&#39;m using, because the context part is coming from <a href="https://github.com/alexedwards/stack" rel="nofollow">Stack</a>. Thanks for that.</p> <blockquote> <p>I don&#39;t use mongo, and I&#39;m not sure I could hook this up to a different data store without modifying the framework itself.</p> </blockquote> <p>Unfortunately, I haven&#39;t documented any of the APIs or how exactly to use the system itself. My bad, but you <em>can</em> use any DB you like, just that you&#39;ll have to add all the required functionalities on your own, and you can set it inside the <em>Globals</em> struct, <em>App</em>, which is a <code>map of string of interface</code>. </p> <blockquote> <p>It looked like you&#39;re doing a bunch of unnecessary manual json decoding for the config; I&#39;m not sure why you didn&#39;t just use encoding/json.Unmarshal.</p> </blockquote> <p>True, I should have. Again, I&#39;m using a 3rd party library to read JSON (<a href="https://github.com/bitly/go-simplejson" rel="nofollow">Simple Json</a>), why I did this is so that you can include any config in your JSON file, not just the framework&#39;s. And you wouldn&#39;t have to define a struct to read it. And I thought I could let the <em>unnecessary</em> json reading stuff slip, since it&#39;s only a one time thing, when starting up the server.</p> <p><strong>Thanks a lot for the feedback!</strong></p> <p>P.S: I will be updating the <a href="https://github.com/bnkamalesh/webgo-sample" rel="nofollow">webgo-sample</a>, showing how to use all the APIs of the framework.</p></pre>lansellot: <pre><p>Go. Not GoLang, not golang, not Golang. Just Go.</p></pre>

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

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