MCPcopy Create free account
hub / github.com/QuantumNous/new-api / UpdateTaskPluginMarketplaceSources

Function UpdateTaskPluginMarketplaceSources

controller/task_plugin.go:878–912  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

876}
877
878func UpdateTaskPluginMarketplaceSources(c *gin.Context) {
879 var sources []setting.TaskPluginMarketplaceSource
880 if err := c.ShouldBindJSON(&sources); err != nil {
881 common.ApiErrorMsg(c, err.Error())
882 return
883 }
884 if sources == nil {
885 sources = []setting.TaskPluginMarketplaceSource{}
886 }
887 for i := range sources {
888 name := strings.TrimSpace(sources[i].Name)
889 indexURL := strings.TrimSpace(sources[i].IndexURL)
890 if name == "" {
891 common.ApiErrorMsg(c, "marketplace source name is required")
892 return
893 }
894 parsed, err := url.Parse(indexURL)
895 if err != nil || !parsed.IsAbs() || parsed.Host == "" || (!strings.EqualFold(parsed.Scheme, "http") && !strings.EqualFold(parsed.Scheme, "https")) {
896 common.ApiErrorMsg(c, "marketplace source index_url must be an absolute http(s) URL")
897 return
898 }
899 sources[i].Name = name
900 sources[i].IndexURL = indexURL
901 }
902 encoded, err := common.Marshal(sources)
903 if err != nil {
904 common.ApiError(c, err)
905 return
906 }
907 if err = model.UpdateOption(setting.TaskPluginMarketplaceSourcesKey, string(encoded)); err != nil {
908 common.ApiError(c, err)
909 return
910 }
911 common.ApiSuccess(c, sources)
912}
913
914// relayPaths lists the incoming paths of a plugin's relay routes, each once.
915func relayPaths(meta jsplugin.Meta) []string {

Calls 6

ApiErrorMsgFunction · 0.92
MarshalFunction · 0.92
ApiErrorFunction · 0.92
UpdateOptionFunction · 0.92
ApiSuccessFunction · 0.92
ErrorMethod · 0.45