forked from raystack/frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable resource identifier composing from multiple variables (#84)
- Loading branch information
1 parent
ea97a84
commit 1ba6c1e
Showing
15 changed files
with
300 additions
and
80 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
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 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,40 @@ | ||
package attribute | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/valyala/fasttemplate" | ||
) | ||
|
||
const ( | ||
TypeJSONPayload AttributeType = "json_payload" | ||
TypeGRPCPayload AttributeType = "grpc_payload" | ||
TypeQuery AttributeType = "query" | ||
TypeHeader AttributeType = "header" | ||
TypePathParam AttributeType = "path_param" | ||
TypeConstant AttributeType = "constant" | ||
TypeComposite AttributeType = "composite" | ||
|
||
SourceRequest AttributeType = "request" | ||
SourceResponse AttributeType = "response" | ||
) | ||
|
||
type AttributeType string | ||
|
||
type Attribute struct { | ||
Key string `yaml:"key" mapstructure:"key"` | ||
Type AttributeType `yaml:"type" mapstructure:"type"` | ||
Index string `yaml:"index" mapstructure:"index"` // proto index | ||
Path string `yaml:"path" mapstructure:"path"` | ||
Params []string `yaml:"params" mapstructure:"params"` | ||
Source string `yaml:"source" mapstructure:"source"` | ||
Value string `yaml:"value" mapstructure:"value"` | ||
} | ||
|
||
func Compose(attribute string, attrs map[string]interface{}) string { | ||
if strings.Contains(attribute, "${") { | ||
template := fasttemplate.New(attribute, "${", "}") | ||
return template.ExecuteString(attrs) | ||
} | ||
return attribute | ||
} |
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 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.
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
Oops, something went wrong.