-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from tigrisdata/main
Alpha release
- Loading branch information
Showing
38 changed files
with
1,021 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
api/client/* | ||
|
||
.idea | ||
.vscode | ||
server/service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/grpc-ecosystem/go-grpc-middleware/util/metautils" | ||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime" | ||
) | ||
|
||
const ( | ||
// HeaderRequestTimeout is an end-to-end request header that indicates the maximum time that a client is | ||
// prepared to await a response. The value of the header is in seconds. A client is allowed to send fractional | ||
// values. For ex, 0.1 means 100milliseconds. | ||
HeaderRequestTimeout = "Request-Timeout" | ||
|
||
HeaderPrefix = "Tigris-" | ||
|
||
HeaderTxID = "Tigris-Tx-Id" | ||
HeaderTxOrigin = "Tigris-Tx-Origin" | ||
|
||
grpcGatewayPrefix = "grpc-gateway-" | ||
) | ||
|
||
func CustomMatcher(key string) (string, bool) { | ||
switch key { | ||
case HeaderRequestTimeout: | ||
return key, true | ||
default: | ||
if strings.HasPrefix(key, HeaderPrefix) { | ||
return key, true | ||
} | ||
return runtime.DefaultHeaderMatcher(key) | ||
} | ||
} | ||
|
||
func GetHeader(ctx context.Context, header string) string { | ||
if val := metautils.ExtractIncoming(ctx).Get(header); val != "" { | ||
return val | ||
} | ||
|
||
return metautils.ExtractIncoming(ctx).Get(grpcGatewayPrefix + header) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.