Monorepo for Tangled tangled.org

appview/keys: be a little more http

Changed files
+13 -3
appview
state
knotserver
+8 -3
appview/state/state.go
··· 160 160 user = strings.TrimPrefix(user, "@") 161 161 162 162 if user == "" { 163 - w.Write([]byte("not found")) 163 + w.WriteHeader(http.StatusBadRequest) 164 164 return 165 165 } 166 166 167 167 id, err := auth.ResolveIdent(r.Context(), user) 168 168 if err != nil { 169 - w.Write([]byte("not found")) 169 + w.WriteHeader(http.StatusInternalServerError) 170 170 return 171 171 } 172 172 173 173 pubKeys, err := s.db.GetPublicKeys(id.DID.String()) 174 174 if err != nil { 175 - w.Write([]byte("not found")) 175 + w.WriteHeader(http.StatusNotFound) 176 + return 177 + } 178 + 179 + if len(pubKeys) == 0 { 180 + w.WriteHeader(http.StatusNotFound) 176 181 return 177 182 } 178 183
+5
knotserver/jetstream.go
··· 177 177 } 178 178 defer resp.Body.Close() 179 179 180 + if resp.StatusCode == http.StatusNotFound { 181 + l.Info("no keys found for did", "did", did) 182 + return nil 183 + } 184 + 180 185 if ct := resp.Header.Get("Content-Type"); !strings.HasPrefix(ct, "text/plain") { 181 186 return fmt.Errorf("unexpected content type: %s", ct) 182 187 }