Skip to content

Commit

Permalink
add an api route for the list of supported languages
Browse files Browse the repository at this point in the history
  • Loading branch information
srujangit123 committed Dec 29, 2024
1 parent 9f6d403 commit de9e15c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ func RegisterRoutes(r *gin.Engine, client codecontainer.ContainerClient, config
Output: output,
})
})

r.GET("/api/v1/languages", func(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"languages": config.GetSupportedLanguages(),
})
})
}
8 changes: 8 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func (c *ImageConfig) IsLanguageSupported(lang Language) bool {
return ok
}

func (c *ImageConfig) GetSupportedLanguages() []Language {
var languages []Language

Check failure on line 57 in pkg/config/config.go

View workflow job for this annotation

GitHub Actions / lint

Consider pre-allocating `languages` (prealloc)
for lang := range *c {
languages = append(languages, lang)
}
return languages
}

func GetHostLanguageCodePath(lang Language) string {
return filepath.Join(BaseCodePath, string(lang))
}
Expand Down

0 comments on commit de9e15c

Please sign in to comment.