mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-19 05:54:43 +08:00
api: return 500 instead of 404 in case of non-existing items (#2582)
This is needed to differentiate between calls to non-existent andpoints and calls to valid endpoints, but with an ID pointing to a non-existing item, and to return JSON in the latter case.
This commit is contained in:
@@ -398,7 +398,7 @@ func (s *rtspServer) apiConnsGet(uuid uuid.UUID) (*apiRTSPConn, error) {
|
||||
|
||||
conn := s.findConnByUUID(uuid)
|
||||
if conn == nil {
|
||||
return nil, errAPINotFound
|
||||
return nil, fmt.Errorf("connection not found")
|
||||
}
|
||||
|
||||
return conn.apiItem(), nil
|
||||
@@ -443,7 +443,7 @@ func (s *rtspServer) apiSessionsGet(uuid uuid.UUID) (*apiRTSPSession, error) {
|
||||
|
||||
_, sx := s.findSessionByUUID(uuid)
|
||||
if sx == nil {
|
||||
return nil, errAPINotFound
|
||||
return nil, fmt.Errorf("session not found")
|
||||
}
|
||||
|
||||
return sx.apiItem(), nil
|
||||
@@ -462,7 +462,7 @@ func (s *rtspServer) apiSessionsKick(uuid uuid.UUID) error {
|
||||
|
||||
key, sx := s.findSessionByUUID(uuid)
|
||||
if sx == nil {
|
||||
return errAPINotFound
|
||||
return fmt.Errorf("session not found")
|
||||
}
|
||||
|
||||
sx.close()
|
||||
|
Reference in New Issue
Block a user