Skip to content

Commit

Permalink
fixup json for file contents
Browse files Browse the repository at this point in the history
  • Loading branch information
sctsui committed May 22, 2019
1 parent c84a461 commit 004a890
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 0 additions & 3 deletions plugins/generator/gencalls/project_gencalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ func (d *ProjectHandler) generate(val *model.Project) []fileEntry {
//append a struct of name/body for every custom plugin in project
for _, customPlugin := range val.CustomPlugin{
pluginDirectoryName := strings.ToLower(strings.Replace(customPlugin.PluginName, " ", "_", -1))
d.log.Debugf("custom plugin name is: %s", customPlugin.GetPluginName())
d.log.Debugf("custom package name is: %s", customPlugin.PackageName)
d.log.Debugf("plugin directory name is :", pluginDirectoryName)
pluginDocContents := d.FillDocTemplate(customPlugin.PackageName)
pluginOptionsContents := d.FillOptionsTemplate(customPlugin)
pluginImplContents := d.FillImplTemplate(customPlugin)
Expand Down
16 changes: 9 additions & 7 deletions plugins/restapi/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ type File struct{
// FilePath struct used to specify file in template structure
// can be "/{pluginName}/doc" or "/doc" if agent-level file
type FilePath struct{
filePath string
FilePath string
}

// FileContents struct to return contents of generated code file
type FileContents struct{
fileContents string
FileContents string
}

// Registers REST handlers
Expand Down Expand Up @@ -145,7 +145,8 @@ func (p *Plugin) LoadProjectHandler(formatter *render.Render) http.HandlerFunc {
w.Header().Set("Content-Type", "application/json")
projectJSON, _ := json.Marshal(projectInfo)

p.logError(formatter.JSON(w, http.StatusOK, projectJSON))
w.WriteHeader(http.StatusOK)
w.Write(projectJSON)
}
}

Expand Down Expand Up @@ -239,12 +240,13 @@ func (p *Plugin) FileContentsHandler(formatter *render.Render) http.HandlerFunc
return
}

fileContents := p.getFileContents(templatePrefix, "structure/" + pID + reqParam.filePath)
fileContents := p.getFileContents(templatePrefix, "structure/" + pID + reqParam.FilePath)

// Send value back to client
w.Header().Set("Content-Type", "application/json")
contentsJson, _ := json.Marshal(fileContents)
p.logError(formatter.JSON(w, http.StatusOK, contentsJson))
w.WriteHeader(http.StatusOK)
w.Write(contentsJson)
}
}

Expand Down Expand Up @@ -307,7 +309,7 @@ func (p *Plugin) genUpdater(proj Project, prefix string, key string) {
if err := broker.Put(key, value); err != nil {
p.Log.Errorf("Put failed: %v", err)
}
p.Log.Debugf("kv store should have (key) %v at (prefix) %v", key, prefix)
p.Log.Debugf("kv store should have (key): %v at (prefix): %v", key, prefix)
}

// returns the Project at specified key {projectName}
Expand Down Expand Up @@ -410,7 +412,7 @@ func (p *Plugin) getFileContents(prefix string, key string) interface{} {
}

contents := FileContents{
fileContents: value.Content,
FileContents: value.Content,
}
return contents
}
Expand Down

0 comments on commit 004a890

Please sign in to comment.