feat: improve compression handling and add global request handler support #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes, including improvements to error handling, updates to dependencies, the addition of a global request handler, and the removal of unused code. Below is a summary of the most important changes grouped by theme.
Error Handling Improvements:
Compressmethod incompress/compression.goto add error handling when retrieving a compressor from the pool. If the object is not of the expected type, an error is returned.Dependency Updates:
go.mod, includinggolang.org/x/netandgoogle.golang.org/genproto, and removed unused indirect dependencies such asgo.opentelemetry.io/otel.go.work.sum, includinggolang.org/x/crypto,golang.org/x/net, andgolang.org/x/tools.Global Request Handler Addition:
globalHandlerfield in theserverOptionsstruct inserver_option.go, allowing the server to define a global handler for all requests.GlobalHandlerfunction inserver_option.goto configure theglobalHandleroption. This handler wraps all requests that do not match registered services or methods.NewServerfunction inserver.goto apply theglobalHandlerto the HTTP handler chain if it is configured.Code Cleanup:
contextWithResponseWriterandResponseWriterFromContextfunctions fromsrpc.go, simplifying the codebase.contextWithResponseWritercall in theServeHTTPmethod ofsrpc.go.…