Skip to content

Commit

Permalink
Add api getLanguage to get webapp perfered language
Browse files Browse the repository at this point in the history
  • Loading branch information
hit9 committed Mar 3, 2016
1 parent 77fe2f7 commit 5926ae3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions webapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ func getInterval(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
func getNotice(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ResponseJSONOK(w, cfg.Webapp.Notice)
}

// getLanguage returns config.webapp.language.
type languageResponse struct {
Language string `json:"language"`
}

func getLanguage(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ResponseJSONOK(w, &languageResponse{cfg.Webapp.Language})
}
18 changes: 18 additions & 0 deletions webapp/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,23 @@ Baisc auth required.
"version": "0.1.1"
}
25. Get webapp notice.
GET /api/notice
200
{
"name": "url"
}
26. Get webapp language.
GET /api/language
200
{
"language": "zh"
}
*/
package webapp
1 change: 1 addition & 0 deletions webapp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func Start(c *config.Config, d *storage.DB, f *filter.Filter) {
router.GET("/api/config", auth.handler(getConfig))
router.GET("/api/interval", getInterval)
router.GET("/api/notice", getNotice)
router.GET("/api/language", getLanguage)
router.GET("/api/projects", getProjects)
router.GET("/api/project/:id", getProject)
router.POST("/api/project", auth.handler(createProject))
Expand Down

0 comments on commit 5926ae3

Please sign in to comment.