MCPcopy
hub / github.com/perkeep/perkeep / serveHTTPPost

Method serveHTTPPost

pkg/importer/importer.go:1249–1282  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

1247}
1248
1249func (ia *importerAcct) serveHTTPPost(w http.ResponseWriter, r *http.Request) {
1250 // TODO: XSRF token
1251
1252 switch r.FormValue("mode") {
1253 case "":
1254 // Nothing.
1255 case "start":
1256 ia.start()
1257 case "stop":
1258 ia.stop()
1259 case "login":
1260 ia.setup(w, r)
1261 return
1262 case "toggleauto":
1263 if err := ia.toggleAuto(); err != nil {
1264 http.Error(w, err.Error(), 500)
1265 return
1266 }
1267 case "togglepaidapi":
1268 ia.usePaidAPI = r.FormValue("usePaidAPI") == "on"
1269 case "delete":
1270 ia.stop() // can't hurt
1271 if err := ia.delete(); err != nil {
1272 http.Error(w, err.Error(), 500)
1273 return
1274 }
1275 http.Redirect(w, r, ia.im.URL(), http.StatusFound)
1276 return
1277 default:
1278 http.Error(w, "Unknown mode", http.StatusBadRequest)
1279 return
1280 }
1281 http.Redirect(w, r, ia.AccountURL(), http.StatusFound)
1282}
1283
1284func (ia *importerAcct) setup(w http.ResponseWriter, r *http.Request) {
1285 if err := ia.im.impl.ServeSetup(w, r, &SetupContext{

Callers 1

ServeHTTPMethod · 0.95

Calls 8

startMethod · 0.95
stopMethod · 0.95
setupMethod · 0.95
toggleAutoMethod · 0.95
deleteMethod · 0.95
AccountURLMethod · 0.95
ErrorMethod · 0.45
URLMethod · 0.45

Tested by

no test coverage detected