ServeHTTP serves clients directly hitting the engine API (i.e. main client callers, not nested execs like module functions)
(w http.ResponseWriter, r *http.Request)
| 1035 | |
| 1036 | // ServeHTTP serves clients directly hitting the engine API (i.e. main client callers, not nested execs like module functions) |
| 1037 | func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 1038 | clientMetadata, err := engine.ClientMetadataFromHTTPHeaders(r.Header) |
| 1039 | if err != nil { |
| 1040 | http.Error(w, fmt.Sprintf("failed to get client metadata: %v", err), http.StatusInternalServerError) |
| 1041 | return |
| 1042 | } |
| 1043 | |
| 1044 | if !engine.CheckVersionCompatibility(engine.NormalizeVersion(clientMetadata.ClientVersion), engine.MinimumClientVersion) { |
| 1045 | http.Error(w, fmt.Sprintf("incompatible client version %s", engine.NormalizeVersion(clientMetadata.ClientVersion)), http.StatusInternalServerError) |
| 1046 | return |
| 1047 | } |
| 1048 | |
| 1049 | httpHandlerFunc(srv.serveHTTPToClient, &ClientInitOpts{ |
| 1050 | ClientMetadata: clientMetadata, |
| 1051 | }).ServeHTTP(w, r) |
| 1052 | } |
| 1053 | |
| 1054 | // ServeHTTPToNestedClient serves nested clients, including module function calls. |
| 1055 | func (srv *Server) ServeHTTPToNestedClient( |
no test coverage detected