comparison src/kaigo/horori/searcher/server/searcher.go @ 56:7396e7407abd

searcher version up.
author pyon@macmini
date Sat, 27 Jun 2020 16:25:13 +0900
parents 4e14902379da
children 0369656be06c
comparison
equal deleted inserted replaced
55:4877160411cc 56:7396e7407abd
1 /* 1 /*
2 Last Change: 2020-05-01 金 10:46:51. 2 Last Change: 2020-06-23 火 15:48:49.
3 */ 3 */
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
94 log.Fatal(err) 94 log.Fatal(err)
95 } 95 }
96 96
97 // Http-Handler 97 // Http-Handler
98 http.HandleFunc("/h/", hhs_handler) // Get /h/0800012345 -> name:addr:20200101#20210701#... 98 http.HandleFunc("/h/", hhs_handler) // Get /h/0800012345 -> name:addr:20200101#20210701#...
99 http.HandleFunc("/hn/", hhsnm_handler) // Get /h/0800012345:0800098765:... -> name1:name2:... 99 http.HandleFunc("/hn/", hhsnm_handler) // Get /hn/0800012345:0800098765:... -> name1:name2:...
100 http.HandleFunc("/ht/", hhstm_handler) // Get /ht/ -> 2020-03-14 12:34 (2020-04-02) 100 http.HandleFunc("/ht/", hhstm_handler) // Get /ht/ -> 2020-03-14 12:34 (2020-04-02)
101 http.HandleFunc("/ha/", hhsdb_handler) // Get /ha/ -> hhsdb.csv for Mover 101 http.HandleFunc("/ha/", hhsdb_handler) // Get /ha/ -> hhsdb.csv for Mover
102 http.HandleFunc("/i/", image_handler) // Get /i/20200110/0800012345.tgz 102 http.HandleFunc("/i/", image_handler) // Get /i/20200110/0800012345.tgz
103 http.HandleFunc("/r/", recent_handler) // Get /r/0800012345:0800067890:0800099999:... -> 0800012345,name1,20200101:0800067890,name2,20210405:... 103 http.HandleFunc("/r/", recent_handler) // Get /r/0800012345:0800067890:0800099999:... -> 0800012345,name1,20200101:0800067890,name2,20210405:...
104 http.HandleFunc("/d/", index_handler) // Get /d/20xx -> 20xx0401:20xx0408:... , /d/20xx0401 -> 0800012345:0800098765:... 104 http.HandleFunc("/d/", index_handler) // Get /d/20xx -> 20xx0401:20xx0408:... , /d/20xx0401 -> 0800012345:0800098765:...
105 http.HandleFunc("/dt/", indextm_handler) // Get /dt/ -> 2020-03-14 12:34 (2020-04-02) 105 http.HandleFunc("/dt/", indextm_handler) // Get /dt/ -> 2020-03-14 12:34 (2020-04-02)
106 http.HandleFunc("/hd/", hhsdbidx_handler)// Get /hd/ -> 20010401,0800012345,name1\n20010401,0300011111,name2\n...
106 http.HandleFunc("/ud/", upidx_handler) // Get /ud/20200402 107 http.HandleFunc("/ud/", upidx_handler) // Get /ud/20200402
107 http.HandleFunc("/u/", uphhsdb_handler) // POST /u/ 108 http.HandleFunc("/u/", uphhsdb_handler) // POST /u/
108 http.HandleFunc("/ui/", upimage_handler) // POST /ui/20200401/0800012345.tgz 109 http.HandleFunc("/ui/", upimage_handler) // POST /ui/20200401/0800012345.tgz
109 http.HandleFunc("/ci/", climage_handler) // Get /ci/20200402 110 http.HandleFunc("/ci/", climage_handler) // Get /ci/20200402 -> remove dir
110 http.HandleFunc("/pw/", pw_handler) // Get /pw/ -> id1:pw1:id2:pw2:... 111 http.HandleFunc("/pw/", pw_handler) // Get /pw/ -> id1:pw1:id2:pw2:...
111 112
112 log.Fatal(http.ListenAndServe(server, nil)) 113 log.Fatal(http.ListenAndServe(server, nil))
113 } 114 }
114 115
386 date = t.Format("2006-01-02 15:04 ") + latest 387 date = t.Format("2006-01-02 15:04 ") + latest
387 } 388 }
388 w.Write([]byte(date)) 389 w.Write([]byte(date))
389 } 390 }
390 391
392 /* Get /hd/ -> 20010401,0800012345,name1\n20010401,0300011111,name2\n... */
393 func hhsdbidx_handler(w http.ResponseWriter, r *http.Request) {
394 s := ""
395 b, err := ioutil.ReadFile(indexdb)
396 if err != nil {
397 return
398 }
399 rd := csv.NewReader(strings.NewReader(string(b)))
400 for {
401 record, err := rd.Read()
402 if err == io.EOF {
403 break
404 }
405 if err != nil {
406 return
407 }
408 s += strings.Join([]string{record[1], record[0], hhash[record[0]].Name}, ",")
409 s += "\n"
410 }
411 w.Write([]byte(s))
412 }
413
391 /* Get /ud/20200402 */ 414 /* Get /ud/20200402 */
392 func upidx_handler(w http.ResponseWriter, r *http.Request) { 415 func upidx_handler(w http.ResponseWriter, r *http.Request) {
393 date := r.URL.Path[len("/ud/"):] 416 date := r.URL.Path[len("/ud/"):]
394 var buf []string 417 var buf []string
395 418