TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Martini: Classy web development in Go

86 点作者 abhia超过 11 年前

12 条评论

simonw超过 11 年前
I really like the look of this. There&#x27;s some very clever API design going on here, and it&#x27;s clearly taking advantage of Go&#x27;s language features rather than just trying to be a clone of a framework from another language.<p>I particularly like the service injection concept. Django forces every view function to take a request object and return a response object. Flask makes these optional, but then requires you to use global variables to access more information from the request. Martini attempts to resolve any arguments it sees by looking up their static type against a service directory. I think that&#x27;s really clever.<p>The way it allows you to stack up Handlers is neat too. Django does this with either globally applied middleware or per-view-function decorators, but there&#x27;s something really neat about just taking a list of functions for things like authentication and &quot;stacking&quot; them on top of each other - or having that same function applied as middleware to every request using m.Use(func...). Using Context.Next() to allow that middleware to &quot;wrap&quot; a request (the equivalent of Django&#x27;s process_request and process_response pair) is clever as well.<p>Colour me impressed!
评论 #6731461 未加载
评论 #6731969 未加载
steilpass超过 11 年前
A list of Go webframeworks. Sorted by activity. Last commit as of 14. Nov 2013<p><a href="https://github.com/codegangsta/martini" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;codegangsta&#x2F;martini</a> Last commit: 2 hours HN discussion: <a href="https://news.ycombinator.com/item?id=6731022" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6731022</a><p><a href="https://github.com/astaxie/beego" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;astaxie&#x2F;beego</a> Last commit: 1 day ago<p><a href="https://github.com/robfig/revel" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;robfig&#x2F;revel</a> Last commit: 4 days ago <a href="https://news.ycombinator.com/item?id=5996712" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5996712</a><p><a href="https://github.com/aaronlifton/Gooo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;aaronlifton&#x2F;Gooo</a> Last commit: 1 month ago <a href="https://news.ycombinator.com/item?id=5057108" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5057108</a><p><a href="https://github.com/hoisie/web" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hoisie&#x2F;web</a> Last commit: 5 months ago <a href="https://news.ycombinator.com/item?id=6715547" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6715547</a><p><a href="https://github.com/paulbellamy/mango" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;paulbellamy&#x2F;mango</a> Last commit: 9 months ago
评论 #6744601 未加载
codegangsta超过 11 年前
Author here. Super flattered to see all the feedback coming in. I built this package to suit my own picky needs.<p>Martini is meant to be non-intrusive and braindead simple to use. Hope you guys like it!
评论 #6732299 未加载
peferron超过 11 年前
I usually don&#x27;t like video walk-throughs, but this one was very snappy and a pleasure to watch.<p>By a happy coincidence, I was just going to start building an API backend in Go today or tomorrow for a side project, and was thinking about doing it with vanilla Go but now I&#x27;ll probably give Martini a shot (!).
评论 #6731276 未加载
slashclee超过 11 年前
Would be really nice if the demo was in a normal web page instead of a video. (Also, I&#x27;d love to know what vim(?) extension provides the interactive completion with the function signatures! That looks really cool.)
评论 #6731254 未加载
评论 #6731979 未加载
jjsz超过 11 年前
This appeared in reddit[1] before Hacker News and he has already been asked[2] how does this compare to revel and beego.<p>[1] <a href="http://www.reddit.com/r/golang/comments/1qlfvp/martini_classy_web_development_in_go/" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;golang&#x2F;comments&#x2F;1qlfvp&#x2F;martini_class...</a><p>[2] <a href="http://www.reddit.com/r/golang/comments/1qlfvp/martini_classy_web_development_in_go/cde0yez" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;golang&#x2F;comments&#x2F;1qlfvp&#x2F;martini_class...</a>
lukeholder超过 11 年前
Great work Jeremy. Although there are a number of web frameworks similar to Sinatra on go, this feels to me to be the most natural. The care taken to present this well shows this project has promise.<p>Are you looking to make this more full featured with an ORM&#x2F;persistence layer (i.e Rails) or keep it small and similar to Sinatra?
评论 #6731990 未加载
semisight超过 11 年前
Very cool. Reminiscent of express.js, but statically typed and in Go. I may look at this for future projects.
评论 #6731269 未加载
VeejayRampay超过 11 年前
Newbie question here, I&#x27;ve looked into gorilla&#x2F;mux before, how does Martini compare to it? Do they serve the same purpose? Does it offer more features? Is it easier to use?<p>Great-looking website by the way. The first impression is a good impression, it&#x27;s very polished.
评论 #6737331 未加载
ithkuil超过 11 年前
Very nice. It can be easily used to serve subtrees of another go web framework that accepts http.Handler (e.g. appengine):<p><pre><code> m := martini.Classic() &#x2F;&#x2F; ... http.Handle(&quot;&#x2F;&quot;, m)</code></pre>
beefsack超过 11 年前
This is amazing, I love the DI with services! I always preferred Gorilla to things like Revel because it wasn&#x27;t so opinionated, and this seems closer to Gorilla but with this clever idea of services.<p>I threw together an example app with templating and database access as services, I&#x27;m impressed by how concise it is.<p><a href="https://gist.github.com/mickhrmweb/7479583" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;mickhrmweb&#x2F;7479583</a>
forsaken超过 11 年前
Seems to be missing documentation.
评论 #6731258 未加载