FAQ
Been looking around the forum and http docs for about an hour, and it's not
clear to me how to obtain params when the server (that I'm about to build)
receives a GET request.

Ideally, I'd like to be able to get a map when someone calls my server,
i.e.:

I handle a GET request:
     www.mydomain.com/abc/xyz?type=foo,day=friday

I'd like to end up with a map something like:
     "type":"foo"
     "day":"friday"

Is there a way to do this, or should I just parse the URL with regex?
Thanks,
Ken

--
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

  • James Bardin at Jul 11, 2014 at 2:48 pm
    This does url parameters as well as form forms:
    http://golang.org/pkg/net/http/#Request.FormValue


    On Friday, July 11, 2014 10:33:28 AM UTC-4, Ken MacDonald wrote:

    Been looking around the forum and http docs for about an hour, and it's
    not clear to me how to obtain params when the server (that I'm about to
    build) receives a GET request.

    Ideally, I'd like to be able to get a map when someone calls my server,
    i.e.:

    I handle a GET request:
    www.mydomain.com/abc/xyz?type=foo,day=friday

    I'd like to end up with a map something like:
    "type":"foo"
    "day":"friday"

    Is there a way to do this, or should I just parse the URL with regex?
    Thanks,
    Ken
    --
    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.
  • Jason Phillips at Jul 11, 2014 at 2:56 pm
    There is also Url.ParseQuery (http://golang.org/pkg/net/url/#ParseQuery).
    On Friday, July 11, 2014 10:48:33 AM UTC-4, James Bardin wrote:


    This does url parameters as well as form forms:
    http://golang.org/pkg/net/http/#Request.FormValue


    On Friday, July 11, 2014 10:33:28 AM UTC-4, Ken MacDonald wrote:

    Been looking around the forum and http docs for about an hour, and it's
    not clear to me how to obtain params when the server (that I'm about to
    build) receives a GET request.

    Ideally, I'd like to be able to get a map when someone calls my server,
    i.e.:

    I handle a GET request:
    www.mydomain.com/abc/xyz?type=foo,day=friday

    I'd like to end up with a map something like:
    "type":"foo"
    "day":"friday"

    Is there a way to do this, or should I just parse the URL with regex?
    Thanks,
    Ken
    --
    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.
  • Ken MacDonald at Jul 11, 2014 at 3:01 pm
    Jason, James, thanks - one of those should do it.

    On Fri, Jul 11, 2014 at 10:56 AM, Jason Phillips wrote:

    There is also Url.ParseQuery (http://golang.org/pkg/net/url/#ParseQuery).

    On Friday, July 11, 2014 10:48:33 AM UTC-4, James Bardin wrote:


    This does url parameters as well as form forms:
    http://golang.org/pkg/net/http/#Request.FormValue


    On Friday, July 11, 2014 10:33:28 AM UTC-4, Ken MacDonald wrote:

    Been looking around the forum and http docs for about an hour, and it's
    not clear to me how to obtain params when the server (that I'm about to
    build) receives a GET request.

    Ideally, I'd like to be able to get a map when someone calls my server,
    i.e.:

    I handle a GET request:
    www.mydomain.com/abc/xyz?type=foo,day=friday

    I'd like to end up with a map something like:
    "type":"foo"
    "day":"friday"

    Is there a way to do this, or should I just parse the URL with regex?
    Thanks,
    Ken
    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 11, '14 at 2:33p
activeJul 11, '14 at 3:01p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase