(w rest.ResponseWriter, r *rest.Request)
| 256 | } |
| 257 | |
| 258 | func (a *API) analyze(w rest.ResponseWriter, r *rest.Request) { |
| 259 | /* |
| 260 | payload: |
| 261 | { |
| 262 | "path": "...", //path to the project to be examined |
| 263 | "generate": "dockerfile,service,docker-compose" //files to generate |
| 264 | } |
| 265 | |
| 266 | response: |
| 267 | { |
| 268 | "Ok": true, |
| 269 | "Language": "ruby", |
| 270 | "Framework": "rails", |
| 271 | "Warnings": null, |
| 272 | "Dockerfile": "...", |
| 273 | "Service": "...", |
| 274 | "DockerCompose": "..." |
| 275 | } |
| 276 | */ |
| 277 | |
| 278 | type payload struct { |
| 279 | Path string `json:"path"` |
| 280 | Generate string `json:"generate"` |
| 281 | } |
| 282 | var request payload |
| 283 | err := r.DecodeJsonPayload(&request) |
| 284 | if err != nil { |
| 285 | a.Error(w, err.Error(), 7, http.StatusInternalServerError) |
| 286 | return |
| 287 | } |
| 288 | path := request.Path |
| 289 | generate := request.Generate |
| 290 | analysis := analyze_sourcecode(config, path, generate, "", "") |
| 291 | if analysis != nil { |
| 292 | w.WriteJson(analysis) |
| 293 | } else { |
| 294 | a.Error(w, "No supported language and/or framework detected", 6, http.StatusOK) |
| 295 | } |
| 296 | |
| 297 | } |
| 298 | |
| 299 | func analyze_sourcecode(config *Config, path string, generate string, git_repo string, git_branch string) *analysisResult { |
| 300 |
nothing calls this directly
no test coverage detected