- GET /api/health-record/find 按 idCard/phrid/personName/empiId 查询 - 回写平台完整响应(Result.Raw),未建模字段不丢失 - 抽 buildOSIClient 共用构造,verify 与 server 复用 - 默认仅绑 127.0.0.1(端点返回真实档案 PII,避免暴露局域网) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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()
|
|
}
|