Answer the question
In order to leave comments, you need to log in
What is the difference between http.CreateNewMux() and the default muxer?
There are a couple of questions about web programming in go.
1. What is the difference between creating a multiplexer via http.CreateNewMux() and a default multiplexer.
2. Why does Handler take ResponeWriter as arguments by value, and Request as a pointer?
Answer the question
In order to leave comments, you need to log in
1) The only difference is that when calling http.ListenAndServe
, it would be necessary to pass the created ServeMux
. If you only use the standard package net/http
, it's easier to use the default ServeMux, while creating a custom Mux allows you to use packages like github.com/gorilla/mux
2) Good answer on SO: https://stackoverflow.com/ a/13256311/7752659. In short, this http.ResponesWriter
is interface
, and interface
, roughly speaking, is already a pointer. http.Request
is a pointer so that when it changes, the server can "see" these changes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question