Documentation ¶
Overview ¶
Package response response transformer plugin
Index ¶
Constants ¶
View Source
const ( // PluginName response transformer PluginName = "response_transformer" // ErrInvalidJSONType invalid value type ErrInvalidJSONType = 10002 )
Variables ¶
This section is empty.
Functions ¶
func ServerFilter ¶
func ServerFilter(ctx context.Context, req interface{}, handler filter.ServerHandleFunc) (interface{}, error)
ServerFilter sets server-side CORS verification
Types ¶
type KeysConfig ¶
type KeysConfig struct { Keys []string `yaml:"keys,omitempty" json:"keys,omitempty"` KVs []*KV `yaml:"-"` StatusCodes []int `yaml:"status_codes,omitempty" json:"status_codes,omitempty"` StatusCodeMap map[int]struct{} `yaml:"-"` TRPCCodes []trpcpb.TrpcRetCode `yaml:"trpc_codes,omitempty" json:"trpc_codes,omitempty"` TRPCCodeMap map[trpcpb.TrpcRetCode]struct{} `yaml:"-"` }
KeysConfig configuration
type Options ¶
type Options struct { // Remove operations // Remove response headers, in the format of header:status_code, e.g., traceid:401,404 means removing traceid when // the HTTP status code is 401 // If status_code is not specified, it means all statuses RemoveHeaders []*KeysConfig `yaml:"remove_headers,omitempty" json:"remove_headers,omitempty"` // Remove keys in the JSON body, in the format of key:status_code, e.g., suid:401 means removing suid when the HTTP // status code is 401 // If status_code is not specified, it means all statuses // Key supports hierarchical configuration, e.g., common.suid RemoveJSON []*KeysConfig `yaml:"remove_json,omitempty" json:"remove_json,omitempty"` // Rename header configuration fields, in the format of old_header:new_header:status_code // Renamed headers will not be formatted RenameHeaders []*KeysConfig `yaml:"rename_headers,omitempty" json:"rename_headers,omitempty"` // Rename JSON body parameters, in the format of key:val:status_code, e.g., suid:xxx RenameJSON []*KeysConfig `yaml:"rename_json,omitempty" json:"rename_json,omitempty"` // Add headers, in the format of key:val AddHeaders []*KeysConfig `yaml:"add_headers,omitempty" json:"add_headers,omitempty"` // Add JSON body parameters, in the format of key:val:type, e.g., suid:xxx:string AddJSON []*KeysConfig `yaml:"add_json,omitempty" json:"add_json,omitempty"` // Replace operations ReplaceHeaders []*KeysConfig `yaml:"replace_headers,omitempty" json:"replace_headers,omitempty"` // key:val:type format, e.g., suid:xxx:string ReplaceJSON []*KeysConfig `yaml:"replace_json,omitempty" json:"replace_json,omitempty"` // Append operations AppendHeaders []*KeysConfig `yaml:"append_headers,omitempty" json:"append_headers,omitempty"` // key:val:type format, e.g., suid:xxx:string AppendJSON []*KeysConfig `yaml:"append_json,omitempty" json:"append_json,omitempty"` // Replace response body ReplaceBody []*KeysConfig `yaml:"replace_body,omitempty" json:"replace_body,omitempty"` // Allowed parameters AllowJSON []*KeysConfig `yaml:"allow_json,omitempty" json:"allow_json,omitempty"` }
Options parameter options
type Plugin ¶
type Plugin struct { }
Plugin response transformer plugin implementation
func (*Plugin) CheckConfig ¶
CheckConfig validates the plugin configuration and returns the parsed configuration object with types. Used in the ServerFilter method for parsing.
Click to show internal directories.
Click to hide internal directories.