-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (39 loc) · 1.15 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"net/http"
"os"
"github.com/bruvduroiu/pinecone-mock/pinecone"
)
func main() {
router := http.NewServeMux()
host := os.Getenv("PINECONE_MOCK_HOST")
if host == "" {
host = "localhost"
}
port := os.Getenv("PINECONE_MOCK_PORT")
if port == "" {
port = "8080"
}
handler := pinecone.Handler{
Host: host,
Port: port,
}
router.HandleFunc("POST /indexes", handler.CreateIndex)
router.HandleFunc("GET /indexes", handler.ListIndex)
router.HandleFunc("GET /indexes/{index_name}", handler.GetIndexByName)
router.HandleFunc("POST /describe_index_stats", handler.DescribeIndexStats)
router.HandleFunc("POST /vectors/upsert", handler.UpsertVectors)
router.HandleFunc("POST /query", handler.QueryVectors)
router.HandleFunc("GET /vectors/fetch", handler.FetchVectors)
router.HandleFunc("POST /vectors/update", handler.UpdateVector)
router.HandleFunc("POST /vectors/delete", handler.DeleteVector)
router.HandleFunc("GET /vectors/list", handler.ListVectorIDs)
addr := fmt.Sprintf("%s:%s", host, port)
server := http.Server{
Addr: addr,
Handler: router,
}
fmt.Println("Server listening on ", addr)
server.ListenAndServe()
}