An implementation of the Handler ServeHTTP function for the CallbackHandler struct.
(w http.ResponseWriter, r *http.Request)
| 147 | |
| 148 | // An implementation of the Handler ServeHTTP function for the CallbackHandler struct. |
| 149 | func (h CallbackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 150 | t, err := h.auth.Token(STATE_IDENTIFIER, r) |
| 151 | if err != nil { |
| 152 | http.Error(w, "Couldn't get token", http.StatusForbidden) |
| 153 | log.Fatal(err) |
| 154 | } |
| 155 | if st := r.FormValue("state"); st != STATE_IDENTIFIER { |
| 156 | http.NotFound(w, r) |
| 157 | log.Fatalf("State mismatch: %s != %s\n", st, STATE_IDENTIFIER) |
| 158 | } |
| 159 | |
| 160 | h.ch <- t |
| 161 | } |
no outgoing calls