github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/pkg/plugin/responsetransformer/setup.go (about)

     1  package responsetransformer
     2  
     3  import (
     4  	"github.com/hellofresh/janus/pkg/plugin"
     5  	"github.com/hellofresh/janus/pkg/proxy"
     6  )
     7  
     8  func init() {
     9  	plugin.RegisterPlugin("response_transformer", plugin.Plugin{
    10  		Action: setupResponseTransformer,
    11  	})
    12  }
    13  
    14  func setupResponseTransformer(def *proxy.RouterDefinition, rawConfig plugin.Config) error {
    15  	var config Config
    16  	err := plugin.Decode(rawConfig, &config)
    17  	if err != nil {
    18  		return err
    19  	}
    20  
    21  	def.AddMiddleware(NewResponseTransformer(config))
    22  	return nil
    23  }