FAQ
Any thing widely adopted in Go community for web tier? The following
factors should be the primary consideration (at least for me):
   - separate of concern, i.e., providing a high quality MVC framework (URL
routing is normally a one-liner, see the example below)
   - easy way for authentication ( the web programmers normally use one
liner, see the example below)
   - other things I missed here, more discussion / comments are welcome

Here is a Flask (Python) example:

@app.route('/secret_page') # one liner for URL routing@login_required # one liner for authenticationdef secret_page():

     # My service logic...

     pass


As one of the sweet spots for Golang is its concurrency capability,
Tornado/Twisted like framework can handle async request much efficiently
(but still programming them needs a certain learning curve). The framework
I'd like to try out in Go is the one that give me programming friendliness
as I described above using Flask code as example (i.e., MVC and sequential
logic thinking), yet giving me the async web request serving capability
(hopefully with same friendliness).



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Matt Silverlock at Jul 9, 2014 at 11:48 pm
    Go has a "built in" framework in the way of its net/http
    (http://golang.org/pkg/net/http/) package—think Ruby's Rack interface on
    steroids.

        - *Requests are served concurrently by default (each request lives in
        its own goroutine)*
        - Routing is easy:

    package main

    import "net/http"

    *func main() {
    * r := http.NewServeMux() r.HandleFunc("/", IndexHandler)
         http.ListenAndServe(":8000", r)}

    func IndexHandler(w http.ResponseWriter, r *http.Request) { // Do whatever you'd like here - e.g.
         w.Write([]byte("Hello World"))}



        - Everything is centered around the http.Handler interface - you can
        make a custom handler type that returns a status code and an error, and
        write a ServeHTTP() method (to satisfy the interface) that handles the
        error and serves a standard error page based on 404|500|etc
        - There's toolkits and micro-frameworks like Gorilla
        (http://www.gorillatoolkit.org/), Goji (https://goji.io/) and gocraft/web
        (https://github.com/gocraft/web/) that give you options for improved
        routing (named params), request contexts (passing data alongside a request,
        like Django's request.META dict), sessions and other middleware.
        - Go does not include any "standard" middleware like Flask might, but
        that's because Go typically aims to be composable (i.e. you're the glue).
        But thanks to the aforementioned http.Handler, it's easy to write stuff and
        share it: gorilla/handlers has some default logging & gzip handlers that
        work with net/http (and anything that respects http.Handler) and I can plug
        my own little project that does HTTP Basic
        Auth: https://github.com/goji/httpauth

    What Go might not give you—because the community is (mostly) focused on
    modular components—is something that's "kitchen sink" like Django. If
    you're trying to get a CMS or news site out the door in < 6 months and
    don't need the performance that Go gives you any time soon, then Django is
    probably going to help you get to your MVP faster.

    Go, however, is likely going to be easier to maintain in the long run—the
    "productivity" (hate that term...) vs. performance pay-off is very high.
    Most of the "frameworks" are closer to something like Bottle or Pyramid
    than Django or Rails (and you'll find most here will agree that that's a
    positive thing).

    Hope that helps.

    On Thursday, July 10, 2014 5:06:30 AM UTC+8, Sean Bigdatafun wrote:

    Any thing widely adopted in Go community for web tier? The following
    factors should be the primary consideration (at least for me):
    - separate of concern, i.e., providing a high quality MVC framework (URL
    routing is normally a one-liner, see the example below)
    - easy way for authentication ( the web programmers normally use one
    liner, see the example below)
    - other things I missed here, more discussion / comments are welcome

    Here is a Flask (Python) example:

    @app.route('/secret_page') # one liner for URL routing@login_required # one liner for authenticationdef secret_page():

    # My service logic...

    pass


    As one of the sweet spots for Golang is its concurrency capability,
    Tornado/Twisted like framework can handle async request much efficiently
    (but still programming them needs a certain learning curve). The framework
    I'd like to try out in Go is the one that give me programming friendliness
    as I described above using Flask code as example (i.e., MVC and sequential
    logic thinking), yet giving me the async web request serving capability
    (hopefully with same friendliness).


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sean Bigdatafun at Jul 10, 2014 at 12:29 am
    Thanks first, and next follow up questions.

    After quickly went through these micro framework's examples, I got the
    impression that I don't need two sets of frameworks to handle
       -- ORM like apps (synchronous request/response, normally handled by
    Flask/Django)
       -- and Chat like apps (lots of open connections, normally handled by
    frameworks like Tornado/Twisted).

    Instead, with these Go frameworks (or even directly use
    http://golang.org/pkg/net/http/), I don't need to change my thinking back
    and forth because I just view each connection as a linear logic (and that
    linear logic lives in a goroutine).

    Is the above understanding near the truth?


    On Wednesday, July 9, 2014 4:48:41 PM UTC-7, Matt Silverlock wrote:

    Go has a "built in" framework in the way of its net/http (
    http://golang.org/pkg/net/http/) package—think Ruby's Rack interface on
    steroids.

    - *Requests are served concurrently by default (each request lives in
    its own goroutine)*
    - Routing is easy:

    package main

    import "net/http"

    *func main() {
    * r := http.NewServeMux() r.HandleFunc("/", IndexHandler)
    http.ListenAndServe(":8000", r)}

    func IndexHandler(w http.ResponseWriter, r *http.Request) { // Do whatever you'd like here - e.g.
    w.Write([]byte("Hello World"))}



    - Everything is centered around the http.Handler interface - you can
    make a custom handler type that returns a status code and an error, and
    write a ServeHTTP() method (to satisfy the interface) that handles the
    error and serves a standard error page based on 404|500|etc
    - There's toolkits and micro-frameworks like Gorilla (
    http://www.gorillatoolkit.org/), Goji (https://goji.io/) and
    gocraft/web (https://github.com/gocraft/web/) that give you options
    for improved routing (named params), request contexts (passing data
    alongside a request, like Django's request.META dict), sessions and other
    middleware.
    - Go does not include any "standard" middleware like Flask might, but
    that's because Go typically aims to be composable (i.e. you're the glue).
    But thanks to the aforementioned http.Handler, it's easy to write stuff and
    share it: gorilla/handlers has some default logging & gzip handlers that
    work with net/http (and anything that respects http.Handler) and I can plug
    my own little project that does HTTP Basic Auth:
    https://github.com/goji/httpauth

    What Go might not give you—because the community is (mostly) focused on
    modular components—is something that's "kitchen sink" like Django. If
    you're trying to get a CMS or news site out the door in < 6 months and
    don't need the performance that Go gives you any time soon, then Django is
    probably going to help you get to your MVP faster.

    Go, however, is likely going to be easier to maintain in the long run—the
    "productivity" (hate that term...) vs. performance pay-off is very high.
    Most of the "frameworks" are closer to something like Bottle or Pyramid
    than Django or Rails (and you'll find most here will agree that that's a
    positive thing).

    Hope that helps.

    On Thursday, July 10, 2014 5:06:30 AM UTC+8, Sean Bigdatafun wrote:

    Any thing widely adopted in Go community for web tier? The following
    factors should be the primary consideration (at least for me):
    - separate of concern, i.e., providing a high quality MVC framework
    (URL routing is normally a one-liner, see the example below)
    - easy way for authentication ( the web programmers normally use one
    liner, see the example below)
    - other things I missed here, more discussion / comments are welcome

    Here is a Flask (Python) example:

    @app.route('/secret_page') # one liner for URL routing@login_required # one liner for authenticationdef secret_page():

    # My service logic...

    pass


    As one of the sweet spots for Golang is its concurrency capability,
    Tornado/Twisted like framework can handle async request much efficiently
    (but still programming them needs a certain learning curve). The framework
    I'd like to try out in Go is the one that give me programming friendliness
    as I described above using Flask code as example (i.e., MVC and sequential
    logic thinking), yet giving me the async web request serving capability
    (hopefully with same friendliness).


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Matt Silverlock at Jul 10, 2014 at 12:32 am
    That's correct: you write synchronous code and Go's net/http can handle the rest.

    If you make sure that you're not accessing global state (or if you are, that it has locks/is designed to be used that way) it's hard to really mess things up.

    On 10 Jul 2014, at 8:29 AM, Sean Bigdatafun wrote:

    Thanks first, and next follow up questions.

    After quickly went through these micro framework's examples, I got the impression that I don't need two sets of frameworks to handle
    -- ORM like apps (synchronous request/response, normally handled by Flask/Django)
    -- and Chat like apps (lots of open connections, normally handled by frameworks like Tornado/Twisted).

    Instead, with these Go frameworks (or even directly use http://golang.org/pkg/net/http/), I don't need to change my thinking back and forth because I just view each connection as a linear logic (and that linear logic lives in a goroutine).

    Is the above understanding near the truth?



    On Wednesday, July 9, 2014 4:48:41 PM UTC-7, Matt Silverlock wrote:
    Go has a "built in" framework in the way of its net/http (http://golang.org/pkg/net/http/) package--think Ruby's Rack interface on steroids.
    Requests are served concurrently by default (each request lives in its own goroutine)
    Routing is easy:
    package main
    import "net/http"
    func main() {
    r := http.NewServeMux()
    r.HandleFunc("/", IndexHandler)

    http.ListenAndServe(":8000", r)
    }
    func IndexHandler(w http.ResponseWriter, r *http.Request) {
    // Do whatever you'd like here - e.g.
    w.Write([]byte("Hello World"))
    }


    Everything is centered around the http.Handler interface - you can make a custom handler type that returns a status code and an error, and write a ServeHTTP() method (to satisfy the interface) that handles the error and serves a standard error page based on 404|500|etc
    There's toolkits and micro-frameworks like Gorilla (http://www.gorillatoolkit.org/), Goji (https://goji.io/) and gocraft/web (https://github.com/gocraft/web/) that give you options for improved routing (named params), request contexts (passing data alongside a request, like Django's request.META dict), sessions and other middleware.
    Go does not include any "standard" middleware like Flask might, but that's because Go typically aims to be composable (i.e. you're the glue). But thanks to the aforementioned http.Handler, it's easy to write stuff and share it: gorilla/handlers has some default logging & gzip handlers that work with net/http (and anything that respects http.Handler) and I can plug my own little project that does HTTP Basic Auth: https://github.com/goji/httpauth
    What Go might not give you--because the community is (mostly) focused on modular components--is something that's "kitchen sink" like Django. If you're trying to get a CMS or news site out the door in < 6 months and don't need the performance that Go gives you any time soon, then Django is probably going to help you get to your MVP faster.

    Go, however, is likely going to be easier to maintain in the long run--the "productivity" (hate that term...) vs. performance pay-off is very high. Most of the "frameworks" are closer to something like Bottle or Pyramid than Django or Rails (and you'll find most here will agree that that's a positive thing).

    Hope that helps.


    On Thursday, July 10, 2014 5:06:30 AM UTC+8, Sean Bigdatafun wrote:
    Any thing widely adopted in Go community for web tier? The following factors should be the primary consideration (at least for me):
    - separate of concern, i.e., providing a high quality MVC framework (URL routing is normally a one-liner, see the example below)
    - easy way for authentication ( the web programmers normally use one liner, see the example below)
    - other things I missed here, more discussion / comments are welcome

    Here is a Flask (Python) example:
    @app.route('/secret_page') # one liner for URL routing
    @login_required # one liner for authentication
    def secret_page():
    # My service logic...
    pass

    As one of the sweet spots for Golang is its concurrency capability, Tornado/Twisted like framework can handle async request much efficiently (but still programming them needs a certain learning curve). The framework I'd like to try out in Go is the one that give me programming friendliness as I described above using Flask code as example (i.e., MVC and sequential logic thinking), yet giving me the async web request serving capability (hopefully with same friendliness).




    --
    You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
    To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/r8zAyo3wyvM/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Justin Israel at Jul 10, 2014 at 12:35 am
    Someone was just yesterday asking a question on StackOverflow about
    choosing Dart vs Go for their backend server, and I was trying to explain
    the same conclusion you had just came to, about how in Go you don't have to
    think about that Tornado/Twisted callback/async approach in order to
    preserve the concurrency across the application.

    On Thu, Jul 10, 2014 at 12:32 PM, Matt Silverlock wrote:

    That’s correct: you write synchronous code and Go’s net/http can handle
    the rest.

    If you make sure that you’re not accessing global state (or if you are,
    that it has locks/is designed to be used that way) it’s hard to really mess
    things up.


    On 10 Jul 2014, at 8:29 AM, Sean Bigdatafun wrote:

    Thanks first, and next follow up questions.

    After quickly went through these micro framework's examples, I got the
    impression that I don't need two sets of frameworks to handle
    -- ORM like apps (synchronous request/response, normally handled by
    Flask/Django)
    -- and Chat like apps (lots of open connections, normally handled by
    frameworks like Tornado/Twisted).

    Instead, with these Go frameworks (or even directly use
    http://golang.org/pkg/net/http/), I don't need to change my thinking back
    and forth because I just view each connection as a linear logic (and that
    linear logic lives in a goroutine).

    Is the above understanding near the truth?


    On Wednesday, July 9, 2014 4:48:41 PM UTC-7, Matt Silverlock wrote:

    Go has a "built in" framework in the way of its net/http (
    http://golang.org/pkg/net/http/) package—think Ruby's Rack interface on
    steroids.

    - *Requests are served concurrently by default (each request lives in
    its own goroutine)*
    - Routing is easy:

    package main

    import "net/http"

    *func main() {
    * r := http.NewServeMux() r.HandleFunc("/", IndexHandler)
    http.ListenAndServe(":8000", r)}

    func IndexHandler(w http.ResponseWriter, r *http.Request) { // Do whatever you'd like here - e.g.
    w.Write([]byte("Hello World"))}



    - Everything is centered around the http.Handler interface - you can
    make a custom handler type that returns a status code and an error, and
    write a ServeHTTP() method (to satisfy the interface) that handles the
    error and serves a standard error page based on 404|500|etc
    - There's toolkits and micro-frameworks like Gorilla (
    http://www.gorillatoolkit.org/ <http://www.gorillatoolkit.org/>),
    Goji (https://goji.io/) and gocraft/web (https://github.com/gocraft/
    web/) that give you options for improved routing (named params),
    request contexts (passing data alongside a request, like Django's
    request.META dict), sessions and other middleware.
    - Go does not include any "standard" middleware like Flask might, but
    that's because Go typically aims to be composable (i.e. you're the glue).
    But thanks to the aforementioned http.Handler, it's easy to write stuff and
    share it: gorilla/handlers has some default logging & gzip handlers that
    work with net/http (and anything that respects http.Handler) and I can plug
    my own little project that does HTTP Basic Auth:
    https://github.com/goji/httpauth <https://github.com/goji/httpauth>

    What Go might not give you—because the community is (mostly) focused on
    modular components—is something that's "kitchen sink" like Django. If
    you're trying to get a CMS or news site out the door in < 6 months and
    don't need the performance that Go gives you any time soon, then Django is
    probably going to help you get to your MVP faster.

    Go, however, is likely going to be easier to maintain in the long run—the
    "productivity" (hate that term...) vs. performance pay-off is very high.
    Most of the "frameworks" are closer to something like Bottle or Pyramid
    than Django or Rails (and you'll find most here will agree that that's a
    positive thing).

    Hope that helps.

    On Thursday, July 10, 2014 5:06:30 AM UTC+8, Sean Bigdatafun wrote:

    Any thing widely adopted in Go community for web tier? The following
    factors should be the primary consideration (at least for me):
    - separate of concern, i.e., providing a high quality MVC framework
    (URL routing is normally a one-liner, see the example below)
    - easy way for authentication ( the web programmers normally use one
    liner, see the example below)
    - other things I missed here, more discussion / comments are welcome

    Here is a Flask (Python) example:

    @app.route('/secret_page') # one liner for URL routing@login_required # one liner for authenticationdef secret_page():

    # My service logic...

    pass


    As one of the sweet spots for Golang is its concurrency capability,
    Tornado/Twisted like framework can handle async request much efficiently
    (but still programming them needs a certain learning curve). The framework
    I'd like to try out in Go is the one that give me programming friendliness
    as I described above using Flask code as example (i.e., MVC and sequential
    logic thinking), yet giving me the async web request serving capability
    (hopefully with same friendliness).


    --
    You received this message because you are subscribed to a topic in the
    Google Groups "golang-nuts" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/golang-nuts/r8zAyo3wyvM/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    golang-nuts+unsubscribe@googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.


    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Justin Israel at Jul 9, 2014 at 11:49 pm
    Wasn't beego inspired by Tornado and Flask?
    http://beego.me/docs/intro/

    I've been using Martini (even if some people don't like the reflection
    magic) and have liked it so far.
      On 10/07/2014 9:06 AM, "Sean Bigdatafun" wrote:

    Any thing widely adopted in Go community for web tier? The following
    factors should be the primary consideration (at least for me):
    - separate of concern, i.e., providing a high quality MVC framework (URL
    routing is normally a one-liner, see the example below)
    - easy way for authentication ( the web programmers normally use one
    liner, see the example below)
    - other things I missed here, more discussion / comments are welcome

    Here is a Flask (Python) example:

    @app.route('/secret_page') # one liner for URL routing@login_required # one liner for authenticationdef secret_page():

    # My service logic...

    pass


    As one of the sweet spots for Golang is its concurrency capability,
    Tornado/Twisted like framework can handle async request much efficiently
    (but still programming them needs a certain learning curve). The framework
    I'd like to try out in Go is the one that give me programming friendliness
    as I described above using Flask code as example (i.e., MVC and sequential
    logic thinking), yet giving me the async web request serving capability
    (hopefully with same friendliness).



    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Andrewchamberss at Jul 10, 2014 at 12:54 am
    Go doesn't require async io because it doesn't use a 1 to 1 mapping of
    thread to goroutine. It was designed to avoid some of the problems
    associated tornado/twisted async stuff, so i don't think you will really
    find Go people doing that.
    On Thursday, July 10, 2014 9:06:30 AM UTC+12, Sean Bigdatafun wrote:

    Any thing widely adopted in Go community for web tier? The following
    factors should be the primary consideration (at least for me):
    - separate of concern, i.e., providing a high quality MVC framework (URL
    routing is normally a one-liner, see the example below)
    - easy way for authentication ( the web programmers normally use one
    liner, see the example below)
    - other things I missed here, more discussion / comments are welcome

    Here is a Flask (Python) example:

    @app.route('/secret_page') # one liner for URL routing@login_required # one liner for authenticationdef secret_page():

    # My service logic...

    pass


    As one of the sweet spots for Golang is its concurrency capability,
    Tornado/Twisted like framework can handle async request much efficiently
    (but still programming them needs a certain learning curve). The framework
    I'd like to try out in Go is the one that give me programming friendliness
    as I described above using Flask code as example (i.e., MVC and sequential
    logic thinking), yet giving me the async web request serving capability
    (hopefully with same friendliness).


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 9, '14 at 9:06p
activeJul 10, '14 at 12:54a
posts7
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase