28 lines
675 B
Go
28 lines
675 B
Go
package main
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"chis_osi/config"
|
||
|
|
"chis_osi/handler"
|
||
|
|
)
|
||
|
|
|
||
|
|
// runServer 启动 server 模式 HTTP 服务,暴露健康档案查询端点。
|
||
|
|
func runServer(cfg config.Config, addr string) error {
|
||
|
|
client, err := buildOSIClient(cfg)
|
||
|
|
if err != nil {
|
||
|
|
return fmt.Errorf("build osi client: %w", err)
|
||
|
|
}
|
||
|
|
|
||
|
|
hr := handler.NewHealthRecordHandler(client)
|
||
|
|
mux := http.NewServeMux()
|
||
|
|
mux.HandleFunc("/api/health-record/find", hr.Find)
|
||
|
|
|
||
|
|
fmt.Printf("chis_osi server listening on %s\n", addr)
|
||
|
|
fmt.Printf(" GET http://%s/api/health-record/find?idCard=<身份证>\n", addr)
|
||
|
|
|
||
|
|
server := &http.Server{Addr: addr, Handler: mux}
|
||
|
|
return server.ListenAndServe()
|
||
|
|
}
|