chore: add requestInfo and IP to TrackAction
This commit is contained in:
		
							parent
							
								
									08c07fb009
								
							
						
					
					
						commit
						a4824ab93d
					
				
							
								
								
									
										13
									
								
								logs.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								logs.go
									
									
									
									
									
								
							| @ -121,4 +121,17 @@ func logRequest(c *gin.Context,  rtenv *RouteEnv, run string, route string, info | ||||
| 		  "tkn":	   tkn, | ||||
|   	}).Info(infoReq) | ||||
| 	} | ||||
| } | ||||
| func requestInfo(c *gin.Context,  rtenv *RouteEnv, run string, route string, tkn string) LogInfo { | ||||
| 	accept_langs := strings.Split(c.Request.Header.Get("Accept-Language"),";") | ||||
| 	langs := strings.Split(accept_langs[0], ",") | ||||
| 	ip, _ := getIP(c.Request) | ||||
|   return LogInfo{ | ||||
|  		Run:    run, | ||||
|  		Route:   route,  | ||||
|  		Lang:    fmt.Sprintf("%+v",langs), | ||||
|  		Agent:   fmt.Sprintf("%+v",c.Request.UserAgent()), | ||||
| 		Ip:	     ip, | ||||
| 		Tkn:	   tkn, | ||||
|  	} | ||||
| } | ||||
							
								
								
									
										9
									
								
								types.go
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								types.go
									
									
									
									
									
								
							| @ -82,6 +82,14 @@ type ConfigPostData struct { | ||||
| 	Val string `yaml:"val" json:"val"` | ||||
| 	Config cfg.Config	`yaml:"config" json:"config"` | ||||
| } | ||||
| type LogInfo struct { | ||||
| 	Run  string `yaml:"run" json:"run"` | ||||
|  	Route string `yaml:"route" json:"route"` | ||||
|  	Lang string `yaml:"lang" json:"lang"` | ||||
|   Agent string `yaml:"agent" json:"agent"` | ||||
| 	Ip string `yaml:"ip" json:"ip"` | ||||
| 	Tkn string `yaml:"tkn" json:"tkn"` | ||||
| } | ||||
| type TrackAction struct { | ||||
| 	When string `yaml:"when" json:"when"` | ||||
| 	Where string `yaml:"where" json:"where"` | ||||
| @ -89,6 +97,7 @@ type TrackAction struct { | ||||
| 	Context string `yaml:"context" json:"context"` | ||||
| 	Data string `yaml:"data" json:"data"` | ||||
| 	Auth string `yaml:"auth" json:"auth"` | ||||
| 	Ip string `yaml:"ip" json:"ip"` | ||||
| } | ||||
| type PostTrackAction struct { | ||||
| 	When string `yaml:"when" json:"when"` | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user