Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/transport/header_transport.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package transport

var customHeaderKeyStore = contextKeyStore{
keyArr: make([]string, 0),
}

// SetHeaderKeys overrides custom keys with provided array.
func SetHeaderKeys(arr []string) {
//length := len(arr)
customHeaderKeyStore.keyArr = arr
//customHeaderKeyStore.length = length
}

// CustomHeaderKeys returns custom content key list
func CustomHeaderKeys() []string {
return customHeaderKeyStore.keyArr
}
5 changes: 5 additions & 0 deletions server/egin/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ func (c *Container) defaultServerInterceptor() gin.HandlerFunc {
for _, key := range loggerKeys {
if value := tools.ContextValue(ctx.Request.Context(), key); value != "" {
fields = append(fields, elog.FieldCustomKeyValue(key, value))
}
}

for _, key := range transport.CustomHeaderKeys() {
if value := tools.ContextValue(ctx.Request.Context(), key); value != "" {
// x-expose 需要在这里获取
if strings.HasPrefix(key, eapp.EgoHeaderExpose()) {
// 设置到ctx response header
Expand Down
Loading