ServeHTTPToNestedClient serves nested clients, including module function calls.
( w http.ResponseWriter, r *http.Request, nestedClientMetadata *engine.ClientMetadata, callerClientID string, hostServiceProxyToCaller bool, moduleCtx dagql.AnyObjectResult, functionCall dagql.Typed, envCtx dagql.AnyObjectResult, )
| 1053 | |
| 1054 | // ServeHTTPToNestedClient serves nested clients, including module function calls. |
| 1055 | func (srv *Server) ServeHTTPToNestedClient( |
| 1056 | w http.ResponseWriter, |
| 1057 | r *http.Request, |
| 1058 | nestedClientMetadata *engine.ClientMetadata, |
| 1059 | callerClientID string, |
| 1060 | hostServiceProxyToCaller bool, |
| 1061 | moduleCtx dagql.AnyObjectResult, |
| 1062 | functionCall dagql.Typed, |
| 1063 | envCtx dagql.AnyObjectResult, |
| 1064 | ) { |
| 1065 | if nestedClientMetadata == nil { |
| 1066 | http.Error(w, "nested client metadata is nil", http.StatusInternalServerError) |
| 1067 | return |
| 1068 | } |
| 1069 | clientMetadata := nestedClientMetadataForRequest(r.Header, nestedClientMetadata) |
| 1070 | |
| 1071 | var moduleContext dagql.ObjectResult[*core.Module] |
| 1072 | if moduleCtx != nil { |
| 1073 | typed, ok := moduleCtx.(dagql.ObjectResult[*core.Module]) |
| 1074 | if !ok { |
| 1075 | http.Error(w, fmt.Sprintf("nested client module context is %T, not Module", moduleCtx), http.StatusInternalServerError) |
| 1076 | return |
| 1077 | } |
| 1078 | if typed.Self() != nil { |
| 1079 | moduleContext = typed |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | var fnCall *core.FunctionCall |
| 1084 | if functionCall != nil { |
| 1085 | typed, ok := functionCall.(*core.FunctionCall) |
| 1086 | if !ok { |
| 1087 | http.Error(w, fmt.Sprintf("nested client function call is %T, not FunctionCall", functionCall), http.StatusInternalServerError) |
| 1088 | return |
| 1089 | } |
| 1090 | fnCall = typed |
| 1091 | } |
| 1092 | |
| 1093 | var envContext dagql.ObjectResult[*core.Env] |
| 1094 | if envCtx != nil { |
| 1095 | typed, ok := envCtx.(dagql.ObjectResult[*core.Env]) |
| 1096 | if !ok { |
| 1097 | http.Error(w, fmt.Sprintf("nested client env context is %T, not Env", envCtx), http.StatusInternalServerError) |
| 1098 | return |
| 1099 | } |
| 1100 | if typed.Self() != nil { |
| 1101 | envContext = typed |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | var hostServiceProxyClientID string |
| 1106 | if hostServiceProxyToCaller { |
| 1107 | hostServiceProxyClientID = callerClientID |
| 1108 | } |
| 1109 | |
| 1110 | httpHandlerFunc(srv.serveHTTPToClient, &ClientInitOpts{ |
| 1111 | ClientMetadata: clientMetadata, |
| 1112 | CallerClientID: callerClientID, |
nothing calls this directly
no test coverage detected