MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / homeModelsAuthStatus

Function homeModelsAuthStatus

internal/api/server.go:1286–1295  ·  view source on GitHub ↗

homeModelsAuthStatus inspects a home models response for an authentication/error envelope. It returns the HTTP status code to surface (401 for credential issues, 502 otherwise) and true when the payload is an error response rather than model data.

(raw []byte)

Source from the content-addressed store, hash-verified

1284// It returns the HTTP status code to surface (401 for credential issues, 502 otherwise)
1285// and true when the payload is an error response rather than model data.
1286func homeModelsAuthStatus(raw []byte) (int, bool) {
1287 errType := homeModelsErrorType(raw)
1288 if errType == "" {
1289 return 0, false
1290 }
1291 if errType == "no_credentials" || errType == "invalid_credential" {
1292 return http.StatusUnauthorized, true
1293 }
1294 return http.StatusBadGateway, true
1295}
1296
1297func homeModelsErrorType(raw []byte) string {
1298 top, ok := unmarshalHomeModelsTopLevel(raw)

Callers 2

loadHomeModelEntriesMethod · 0.85
TestHomeModelsAuthStatusFunction · 0.85

Calls 1

homeModelsErrorTypeFunction · 0.85

Tested by 1

TestHomeModelsAuthStatusFunction · 0.68