http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
m.SayHello(w, r) })
or you could rename SayHello to ServerHTTP, and then just
http.Handle("/", m)
Dave.
> I'm not sure what "curry" functions means. I see wikipedia talking
> about it, turning a function with multiple arguments into a chain of
> functions. But looking at the page yields very little to my brain.
Yes, that is roughly right. In your original code, you put a method on
a type, and you can only normally ([1]) call methods when you have an
object of that type. You were telling the http package to run a
method, but the package doesn't know the type or have an object to
call that method.
> In your example, I would just pass a closure, seems reasonable.
>
> I'm not sure why changing SayHello to ServerHTTP works....
It's not just renaming, it's also changing which function in the http
package you're calling. http.HandleFunc takes a function with a
particular signature, whereas http.Handle takes an *interface*. Have
you learned about interfaces yet? If not, you probably want to go do
that; [2] might be a good start.
Dave.
[1] There's an exception, but it's not useful to you here. c.f.
http://golang.org/doc/go_spec.html#Method_expressions
[2] http://golang.org/doc/effective_go.html#interfaces_and_types and
http://tour.golang.org/#49