| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -28,13 +28,23 @@ func ResponseHandler(req *http.Request, w http.ResponseWriter, trans bool, resp
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if trans {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						result.Msg = i18n.Trans(req.Context(), result.Msg)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					c := http.StatusInternalServerError
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if result.Type == nstatus.ApiErr {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					var c int
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					switch result.Type {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					case nstatus.ApiErr:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						// API错误,按照Result内的code返回,若code不是标准http错误,则按照500返回
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						c = result.Code
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if c > http.StatusNetworkAuthenticationRequired {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if c > http.StatusNetworkAuthenticationRequired || c < http.StatusContinue {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							c = http.StatusInternalServerError
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					case nstatus.BizErr:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						// 业务代码类型错误,统一状态码为500
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						c = http.StatusInternalServerError
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					case nstatus.RpcErr:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						// RPC错误,统一状态码为500
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						c = http.StatusInternalServerError
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					default:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						c = http.StatusInternalServerError
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 其它错误统一按照500返回
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					httpx.WriteJson(w, c, result)
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |