diff src/kaigo/horori/searcher/server/searcher.go @ 46:6ec28d3c3e00

small changes.
author pyon@macmini
date Sat, 18 Apr 2020 21:10:29 +0900
parents 20b42e2deae1
children 169936fed61b
line wrap: on
line diff
--- a/src/kaigo/horori/searcher/server/searcher.go	Thu Apr 16 20:59:35 2020 +0900
+++ b/src/kaigo/horori/searcher/server/searcher.go	Sat Apr 18 21:10:29 2020 +0900
@@ -1,5 +1,5 @@
  /*
-  Last Change: 2020-04-16 木 17:15:49.
+  Last Change: 2020-04-17 金 17:04:25.
  */
 
 package main
@@ -84,12 +84,14 @@
 	}
 
 	// Http-Handler
-	http.HandleFunc("/h/",  hhs_handler)
-	http.HandleFunc("/ha/", hhsdb_handler)
-	http.HandleFunc("/u/",  uphhsdb_handler)
-	http.HandleFunc("/i/",  image_handler)
-	http.HandleFunc("/r/",  recent_handler)
-	http.HandleFunc("/d/",  index_handler)
+	http.HandleFunc("/h/",  hhs_handler)      // Get /h/0800012345 -> name:addr:20200101#20210701#...
+	http.HandleFunc("/hn/", hhsnm_handler)    // Get /h/0800012345:0800098765:... -> name1:name2:...
+	http.HandleFunc("/ht/", hhstm_handler)    // Get /ht -> 20200314
+	http.HandleFunc("/ha/", hhsdb_handler)    // Get /ha/ -> hhsdb.csv for Mover
+	http.HandleFunc("/i/",  image_handler)    // Get /i/20200110/0800012345.tgz
+	http.HandleFunc("/r/",  recent_handler)   // Get /r/0800012345:0800067890:0800099999:... -> 0800012345,name1,20200101:0800067890,name2,20210405:...
+	http.HandleFunc("/d/",  index_handler)    // Get /d/20xx -> 20xx0401:2020xx0408:... , /d/20xx0401 -> 0800012345:0800098765:...
+	http.HandleFunc("/u/",  uphhsdb_handler)  // Get /u/ -> ?
 
 	log.Fatal(http.ListenAndServe(server, nil))
 }
@@ -152,7 +154,7 @@
 	return nil
 }
 
-/* Get /h/0800012345 -> name:addr:ymd1#ymd2#... */
+/* Get /h/0800012345 -> name:addr:20200101#20210701#... */
 func hhs_handler(w http.ResponseWriter, r *http.Request) {
 	hno := r.URL.Path[len("/h/"):]
 	s := ""
@@ -162,6 +164,26 @@
 	w.Write([]byte(s))
 }
 
+/* Get /hn/0800012345:0800098765:... -> name1:name2:... */
+func hhsnm_handler(w http.ResponseWriter, r *http.Request) {
+	hnolist := strings.Split(r.URL.Path[len("/hn/"):], ":")
+	var buf []string
+	for _, hno := range hnolist {
+		var n string
+		if h, ok := hhash[hno]; ok {
+			n = h.Name
+		}
+		buf = append(buf, n)
+	}
+	w.Write([]byte(strings.Join(buf, ":")))
+}
+
+/* Get /ht > 20200314 */
+func hhstm_handler(w http.ResponseWriter, r *http.Request) {
+	date := ""
+	w.Write([]byte(date))
+}
+
 /* Get /ha/ -> hhsdb.csv for Mover */
 func hhsdb_handler(w http.ResponseWriter, r *http.Request) {
 	b, _ := ioutil.ReadFile(hhsdb)
@@ -187,7 +209,7 @@
 	io.Copy(w, f)
 }
 
-/* Get /r/0800012345:0800067890:0800099999:... */
+/* Get /r/0800012345:0800067890:0800099999:... -> 0800012345,name1,20200101:0800067890,name2,20210405:... */
 func recent_handler(w http.ResponseWriter, r *http.Request) {
 	hnolist := strings.Split(r.URL.Path[len("/r/"):], ":")
 	var buf []string
@@ -217,6 +239,7 @@
 	w.Write([]byte(buf[1:]))
 }
 
+/* /u */
 func uphhsdb_handler(w http.ResponseWriter, r *http.Request) {
 	server_root := filepath.Dir(os.Args[0])
 	file := filepath.Join(server_root, "db", hhsdb)