Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Tushar-kalsi
Copy link
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 .
backend/entities/sensor.go Outdated Show resolved Hide resolved
backend/handlers.go Outdated Show resolved Hide resolved

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

Copy link
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

backend/entities/sensor.go Outdated Show resolved Hide resolved
backend/repos/sensors.go Outdated Show resolved Hide resolved
backend/repos/sensors.go Show resolved Hide resolved

}

func (r *SensorRepo) AddSensors(sensor entities.Sensor, userId string) error {
Copy link
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

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

}
Copy link
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