feat(assist-api): correct response format for getByID
This commit is contained in:
parent
ab1b5c19ec
commit
2e85fc953a
2 changed files with 12 additions and 6 deletions
|
|
@ -135,13 +135,16 @@ func (e *handlersImpl) socketsListByProject(w http.ResponseWriter, r *http.Reque
|
|||
return
|
||||
}
|
||||
|
||||
resp, err := e.assist.IsLive(projectKey, sessionID, req)
|
||||
resp, err := e.assist.GetByID(projectKey, sessionID, req)
|
||||
if err != nil {
|
||||
e.responser.ResponseWithError(e.log, r.Context(), w, http.StatusInternalServerError, err, startTime, r.URL.Path, bodySize)
|
||||
return
|
||||
}
|
||||
e.log.Debug(context.Background(), "socketsListByProject request, projectKey: %s, sessionID: %s, req: %v, response: %v", projectKey, sessionID, req, resp)
|
||||
e.responser.ResponseWithJSON(e.log, r.Context(), w, resp, startTime, r.URL.Path, bodySize)
|
||||
response := map[string]interface{}{
|
||||
"data": resp,
|
||||
}
|
||||
e.responser.ResponseWithJSON(e.log, r.Context(), w, response, startTime, r.URL.Path, bodySize)
|
||||
}
|
||||
|
||||
func (e *handlersImpl) socketsLiveByProject(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -211,5 +214,8 @@ func (e *handlersImpl) socketsLiveBySession(w http.ResponseWriter, r *http.Reque
|
|||
return
|
||||
}
|
||||
e.log.Debug(context.Background(), "socketsLiveBySession request, projectKey: %s, sessionID: %s, req: %v, response: %v", projectKey, sessionID, req, resp)
|
||||
e.responser.ResponseWithJSON(e.log, r.Context(), w, resp, startTime, r.URL.Path, bodySize)
|
||||
response := map[string]interface{}{
|
||||
"data": resp,
|
||||
}
|
||||
e.responser.ResponseWithJSON(e.log, r.Context(), w, response, startTime, r.URL.Path, bodySize)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ type SessionData struct {
|
|||
type SessionManager interface {
|
||||
Start()
|
||||
Stop()
|
||||
GetByID(projectID, sessionID string) (*SessionData, error)
|
||||
GetByID(projectID, sessionID string) (interface{}, error)
|
||||
GetAll(projectID string, filters []*Filter, sort SortOrder, page, limit int) ([]interface{}, int, map[string]map[string]int, error)
|
||||
Autocomplete(projectID string, key FilterType, value string) ([]interface{}, error)
|
||||
}
|
||||
|
|
@ -362,7 +362,7 @@ func (sm *sessionManagerImpl) updateSessions() {
|
|||
sm.log.Debug(sm.ctx, "Session processing cycle completed in %v. Processed %d sessions", duration, len(sm.cache))
|
||||
}
|
||||
|
||||
func (sm *sessionManagerImpl) GetByID(projectID, sessionID string) (*SessionData, error) {
|
||||
func (sm *sessionManagerImpl) GetByID(projectID, sessionID string) (interface{}, error) {
|
||||
if sessionID == "" {
|
||||
return nil, fmt.Errorf("session ID is required")
|
||||
}
|
||||
|
|
@ -377,7 +377,7 @@ func (sm *sessionManagerImpl) GetByID(projectID, sessionID string) (*SessionData
|
|||
if sessionData.ProjectID != projectID {
|
||||
return nil, fmt.Errorf("session does not belong to the project")
|
||||
}
|
||||
return sessionData, nil
|
||||
return sessionData.Raw, nil
|
||||
}
|
||||
|
||||
func (sm *sessionManagerImpl) GetAll(projectID string, filters []*Filter, sort SortOrder, page, limit int) ([]interface{}, int, map[string]map[string]int, error) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue