ffs
This commit is contained in:
parent
e7bd20eae9
commit
434adf1f66
3 changed files with 17 additions and 2 deletions
11
main.go
11
main.go
|
|
@ -20,6 +20,7 @@ var (
|
|||
session *onnxruntime_go.DynamicAdvancedSession
|
||||
maxLen = int64(128)
|
||||
embeddingSize = int64(384)
|
||||
version = "dev"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -218,6 +219,15 @@ func healthHandler(w http.ResponseWriter, r *http.Request) {
|
|||
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
func versionHandler(w http.ResponseWriter, r *http.Request) {
|
||||
v := os.Getenv("SOURCE_COMMIT")
|
||||
if v == "" {
|
||||
v = version
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"version": v})
|
||||
}
|
||||
|
||||
func main() {
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
|
|
@ -226,6 +236,7 @@ func main() {
|
|||
|
||||
http.HandleFunc("/vector", vectorHandler)
|
||||
http.HandleFunc("/ok", healthHandler)
|
||||
http.HandleFunc("/version", versionHandler)
|
||||
log.SetOutput(os.Stdout)
|
||||
log.Printf("Starting server on port %s...\n", port)
|
||||
log.Fatal(http.ListenAndServe(":"+port, loggingMiddleware(http.DefaultServeMux)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue