()
| 142 | } |
| 143 | |
| 144 | func (mux *Multiplexer) init() { |
| 145 | handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 146 | // you can allow only http2 request |
| 147 | //if r.ProtoMajor != 2 { |
| 148 | // log.Println("HTTP/2 request is rejected") |
| 149 | // w.WriteHeader(http.StatusInternalServerError) |
| 150 | // return |
| 151 | //} |
| 152 | |
| 153 | f := mux.GetHandler(r.URL.Path) |
| 154 | if f == nil { |
| 155 | log.Println("unknown path", r.URL.Path) |
| 156 | return |
| 157 | } |
| 158 | f(w, r) |
| 159 | }) |
| 160 | mux.Handler = handler |
| 161 | } |
| 162 | |
| 163 | func (mux *Multiplexer) GetHandler(path string) func(w http.ResponseWriter, r *http.Request) { |
| 164 | f, ok := mux.handlers[path] |
no test coverage detected