L
L
Luke LikeSkywalker2018-09-03 12:07:03
go
Luke LikeSkywalker, 2018-09-03 12:07:03

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 answer(s)
N
Nikita Shoshin, 2018-09-03
@Kirtis

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.ResponesWriteris interface, and interface, roughly speaking, is already a pointer. http.Requestis a pointer so that when it changes, the server can "see" these changes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question