File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 55)
66
77type  rule  struct  {
8- 	Endpoint  string             `mapstructure:"endpoint"` 
9- 	Method    string             `mapstructure:"method"` 
10- 	Headers   map [string ]string  `mapstructure:"headers"` 
11- 	Body      string             `mapstructure:"body"` 
8+ 	Endpoint     string             `mapstructure:"endpoint"` 
9+ 	Method       string             `mapstructure:"method"` 
10+ 	Headers      map [string ]string  `mapstructure:"headers"` 
11+ 	Body         string             `mapstructure:"body"` 
12+ 	ContentType  string             `mapstructure:"content-type"` 
1213}
1314
1415func  (r  * rule ) Defaults () {
@@ -22,4 +23,7 @@ func (r *rule) Defaults() {
2223	if  ! allowedMethod  {
2324		r .Method  =  "POST" 
2425	}
26+ 	if  r .ContentType  ==  ""  {
27+ 		r .ContentType  =  "application/json" 
28+ 	}
2529}
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ func (a *action) prepareRequest(meta types.Data) *http.Request {
6868func  (a  * action ) setRequestHeaders (request  * http.Request ) {
6969	request .Header .Set ("User-Agent" , "Rivi-Agent/1.0" )
7070	request .Header .Set ("X-Rivi-Event" , "trigger" )
71- 	request .Header .Set ("Content-Type" , "application/json" )
71+ 	request .Header .Set ("Content-Type" , a . rule . ContentType )
7272	for  name , value  :=  range  a .rule .Headers  {
7373		lowerName  :=  strings .ToLower (name )
7474		if  ! strings .HasPrefix (lowerName , "x-" ) ||  strings .HasPrefix (lowerName , "x-rivi" ) {
Original file line number Diff line number Diff line change 3232-  ` endpoint `  (required) - the target endpoint
3333-  ` method `  (optional) - HTTP method (` GET `  or ` POST ` ) (default: ** POST** )
3434-  ` headers `  (optional) - key-values to add to request. Must start with ` X- `  otherwise will not be included
35+ -  ` body `  (optional) - Template for posted data
36+ -  ` content-type `  (optional) - Set ` Content-Type `  header (default: ** ` application/json ` ** )
3537
3638## Example  
3739``` yaml 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments