-
Notifications
You must be signed in to change notification settings - Fork 8
Simplify server JSON handler code for RPC methods #36
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
Conversation
6c6c3f9
to
3134536
Compare
3134536
to
f3a2c65
Compare
No need to define defer-panic in JSON handler for each generated RPC method, since the generated Go methods are private and called only from within .ServerHTTP().
RespondWithError(w, ErrorWithCause(ErrWebrpcServerPanic, fmt.Errorf("%v", rr))) | ||
panic(rr) | ||
} | ||
}() |
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.
Move the defer-panic up to the ServeHTTP() method.
No need to define defer-panic in JSON handler for each generated RPC method, since the generated Go methods are private and called only from within .ServerHTTP()
.
panic(rr) | ||
} | ||
}() | ||
ret0, err = s.ExampleService.Status(ctx) |
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.
Move the service call to the main handler function. Remove the unnecessarry anonymous function and a defer call (which was moved up to the parent .ServeHTTP()
method)
No description provided.