-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: added network service - handler and receiver #403
base: beckn-onix-v1.0-develop
Are you sure you want to change the base?
feat: added network service - handler and receiver #403
Conversation
rupinder-syngh
commented
Feb 19, 2025
- Added network handler
- Added network receiver
…onfig structure and some minor tweaks
…yngh/beckn-onix into feat/network_services
@@ -0,0 +1,30 @@ | |||
package config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not need to be a separate package. Move this file to the parent folder and change the package to be main.
log.Println("No .env file found, using default values") | ||
} | ||
|
||
return &Config{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config will be parsed from a confg.yaml file, please refer to Mayur's PR for reference.
cmd/networkSideHandler/main.go
Outdated
"beckn-onix/cmd/networkSideHandler/config" | ||
) | ||
|
||
type CreateUserRequest struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to to this, please do the bare minimum need, for this change we should not do anything other than adding a asingle route which will only accpet post calls and return OK 200
cmd/networkSideHandler/main.go
Outdated
|
||
func CreateUserHandler(w http.ResponseWriter, r *http.Request) { | ||
if r.Method != http.MethodPost { | ||
http.Error(w, "Invalid request method", http.StatusMethodNotAllowed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing all this ?
cmd/networkSideHandler/main_test.go
Outdated
{"Valid request", `{"name": "John Doe", "email": "[email protected]"}`, http.StatusCreated}, | ||
{"Missing name", `{"email": "[email protected]"}`, http.StatusBadRequest}, | ||
{"Missing email", `{"name": "John Doe"}`, http.StatusBadRequest}, | ||
{"Invalid JSON", `{name: "John Doe", email: "[email protected]"}`, http.StatusBadRequest}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format this so this is more readable. basically one line should have just one field.
cmd/networkSideHandler/main_test.go
Outdated
rr := httptest.NewRecorder() | ||
CreateUserHandler(rr, req) | ||
|
||
require.Equal(t, tc.expectedStatus, rr.Code, "Unexpected response status") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please avoid using third party libraries for testing, and stick to using explicit comparisons using standard library features, use this for reference https://golang.cafe/blog/golang-table-test-example
cmd/networkSideHandler/main.go
Outdated
} | ||
|
||
func main() { | ||
cfg := config.LoadConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main function should only call run method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the comments for the handler service
@ashishkgGoogle Coverage is 88.2% |