Skip to content

Fix #92 , Added /Sensor route for GET , POST request to list all sensors .#102

Open
Tushar-kalsi wants to merge 12 commits into
honeynet:mainfrom
Tushar-kalsi:main
Open

Fix #92 , Added /Sensor route for GET , POST request to list all sensors .#102
Tushar-kalsi wants to merge 12 commits into
honeynet:mainfrom
Tushar-kalsi:main

Conversation

@Tushar-kalsi
Copy link
Copy Markdown
Contributor

  • Added /sensor GET request for returning all sensors stored under current user Owner id ,
  • Added /sensor POST request for adding new sensor under current user Owner id .

Please verify my approch and let me know the inputs .
Thanks

Fixed honeynet#96

Some changes in handler.go file in publishHandler function intersepted msg []byte object decode it , made changes as per requirnments .
…ckend

Removed .split ('-')[0] from front end code and already added this logic in backend
I have made changes as per discussion please review .
Added some file for /sensor route.
Added /Sensor route as GET request to list all sensors stored by owner id . POST request for adding sensor under current user id as owner id .
Added /sensor route .
Comment thread backend/entities/sensor.go Outdated
Comment thread backend/handlers.go Outdated
Comment thread backend/handlers.go Outdated

userId := userIDFromCtx(r.Context())
events, err := cs.sensorRepo.GetSensorsByOwnerId(userId)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No newline here needed as the error handling is directly related to the repo call

Comment thread backend/entities/sensor.go Outdated
Comment thread backend/repos/sensors.go Outdated
Comment thread backend/repos/sensors.go
Comment thread backend/repos/sensors.go Outdated

}

func (r *SensorRepo) AddSensors(sensor entities.Sensor, userId string) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only pass the sensor entity, assign the user_id in the handler

Comment thread backend/repos/sensors.go Outdated
Comment on lines +11 to +13
func TestGetSesors(t *testing.T) {

}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implement tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants