Example #1
0
// Encode - json.encode - encodes all values in context from `encode` list to JSON.
// Example:
// 	{
//		"name": "json.encode",
//		"ctx": {
//			"encode": ["content"],
//			"content": [1, 2, 3]
//		}
//	}
func Encode(ctx action.Map) (action.Map, error) {
	// Pop encode value - context keys to encode
	ctx.Transform(ctx.Pop("encode"), encodeFunc)
	return ctx, nil
}
Example #2
0
// TrimSpaces - filter.trim - trims all string values in context from `trim` list.
// Example:
// 	{
//		"name": "filter.trim",
//		"ctx": {
//			"trim": ["content", "other"],
//			"content": "   some content to trim out of white space    ",
//			"other": "   some other content to trim out of white space    "
//		}
//	}
func TrimSpaces(ctx action.Map) (action.Map, error) {
	// Pop trim value - context keys to trim
	ctx.Transform(ctx.Pop("trim"), trimFunc)

	return ctx, nil
}
Example #3
0
// Decode - json.decode - decodes all JSON values in context from `decode` list.
// Example:
// 	{
//		"name": "json.decode",
//		"ctx": {
//			"decode": ["content"],
//			"content": "[1, 2, 3]"
//		}
//	}
func Decode(ctx action.Map) (action.Map, error) {
	// Pop decode value - context keys to decode
	ctx.Transform(ctx.Pop("decode"), decodeFunc)

	return ctx, nil
}