(c *routing.Context)
| 41 | } |
| 42 | |
| 43 | func (controller *Controller) InvokeHandler(c *routing.Context) error { |
| 44 | externalRequestID := string(c.Request.Header.Peek(api.HeaderXRequestID)) |
| 45 | invokeType := strings.ToLower(string(c.Request.Header.Peek(api.HeaderInvokeType))) |
| 46 | triggerType := strings.ToLower(string(c.Request.Header.Peek(api.BceFaasTriggerKey))) |
| 47 | accountID := string(c.Request.Header.Peek(api.HeaderXAccountID)) |
| 48 | authorization := string(c.Request.Header.Peek(api.HeaderAuthorization)) |
| 49 | requestID := id.GetRequestID() |
| 50 | if externalRequestID == "" { |
| 51 | externalRequestID = requestID |
| 52 | } |
| 53 | |
| 54 | if invokeType == "" { |
| 55 | invokeType = api.InvokeTypeCommon |
| 56 | } |
| 57 | if triggerType == "" { |
| 58 | triggerType = api.TriggerTypeGeneric |
| 59 | } |
| 60 | |
| 61 | var clientMode string |
| 62 | if invokeType == api.InvokeTypeEvent || invokeType == api.InvokeTypeMqhub { |
| 63 | clientMode = ClientModeInside |
| 64 | } |
| 65 | if triggerType == api.TriggerTypeVscode { |
| 66 | clientMode = ClientModeInside |
| 67 | } |
| 68 | |
| 69 | ctx := InvokeContext{ |
| 70 | RunOptions: controller.runOptions, |
| 71 | ExternalRequestID: externalRequestID, |
| 72 | RequestID: requestID, |
| 73 | AccountID: accountID, |
| 74 | Authorization: authorization, |
| 75 | CallerUser: &api.User{ |
| 76 | ID: accountID, |
| 77 | }, |
| 78 | Clients: controller.NewClients(clientMode), |
| 79 | Request: generateInvokeRequest(c), |
| 80 | Response: api.NewInvokeProxyResponseWithRequestID(externalRequestID), |
| 81 | Logger: logs.NewLogger().WithField("request_id", requestID). |
| 82 | WithField("external_request_id", externalRequestID).WithField("invoke-type", invokeType), |
| 83 | LogType: api.GetLogType(c), |
| 84 | LogToBody: api.GetLogToBody(c), |
| 85 | InvokeType: invokeType, |
| 86 | TriggerType: triggerType, |
| 87 | } |
| 88 | |
| 89 | funcName := c.Param("functionName") |
| 90 | if !api.RegfunctionName.MatchString(funcName) { |
| 91 | ctx.FunctionBRN = funcName |
| 92 | } else { |
| 93 | qualifier := string(c.QueryArgs().Peek("Qualifier")) |
| 94 | if qualifier == "" { |
| 95 | c.Response.SetStatusCode(http.StatusBadRequest) |
| 96 | err := innerErr.NewInvalidParameterValueException("missing query parameter Qualifier", nil) |
| 97 | bodyData, _ := json.Marshal(err) |
| 98 | c.Response.SetBody(bodyData) |
| 99 | return err |
| 100 | } |
nothing calls this directly
no test coverage detected