(ctx *gin.Context, teamID string, input *service_dto.CreateService)
| 669 | } |
| 670 | |
| 671 | func (i *imlServiceController) Create(ctx *gin.Context, teamID string, input *service_dto.CreateService) (*service_dto.Service, error) { |
| 672 | if input.Kind == "ai" { |
| 673 | return i.createAIService(ctx, teamID, input) |
| 674 | } |
| 675 | var err error |
| 676 | var info *service_dto.Service |
| 677 | err = i.transaction.Transaction(ctx, func(ctx context.Context) error { |
| 678 | info, err = i.module.Create(ctx, teamID, input) |
| 679 | if err != nil { |
| 680 | return err |
| 681 | } |
| 682 | path := fmt.Sprintf("/%s/", strings.Trim(input.Prefix, "/")) |
| 683 | _, err = i.routerModule.Create(ctx, info.Id, &router_dto.Create{ |
| 684 | Id: uuid.New().String(), |
| 685 | Name: "", |
| 686 | Path: path + "*", |
| 687 | Methods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch, http.MethodOptions}, |
| 688 | Description: "auto create by create service", |
| 689 | Protocols: []string{"http", "https"}, |
| 690 | MatchRules: nil, |
| 691 | Upstream: "", |
| 692 | Proxy: &router_dto.InputProxy{ |
| 693 | Path: path, |
| 694 | Timeout: 30000, |
| 695 | Retry: 0, |
| 696 | }, |
| 697 | Disable: false, |
| 698 | }) |
| 699 | apps, err := i.appModule.Search(ctx, teamID, "") |
| 700 | if err != nil { |
| 701 | return err |
| 702 | } |
| 703 | for _, app := range apps { |
| 704 | i.subscribeModule.AddSubscriber(ctx, info.Id, &subscribe_dto.AddSubscriber{ |
| 705 | Application: app.Id, |
| 706 | }) |
| 707 | } |
| 708 | return err |
| 709 | }) |
| 710 | return info, err |
| 711 | } |
| 712 | |
| 713 | func (i *imlServiceController) Edit(ctx *gin.Context, id string, input *service_dto.EditService) (*service_dto.Service, error) { |
| 714 | info, err := i.Get(ctx, id) |
nothing calls this directly
no test coverage detected