MCPcopy Index your code
hub / github.com/dagger/dagger / ServeHTTP

Method ServeHTTP

engine/server/session.go:1037–1052  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1035
1036// ServeHTTP serves clients directly hitting the engine API (i.e. main client callers, not nested execs like module functions)
1037func (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.
1055func (srv *Server) ServeHTTPToNestedClient(

Callers 4

mainFunction · 0.95
serveHTTPToClientMethod · 0.45
serveQueryMethod · 0.45

Calls 5

NormalizeVersionFunction · 0.92
httpHandlerFuncFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected