admin: new route to export nginx translation file from team name to team_id
This commit is contained in:
parent
20df137eeb
commit
93f36faafe
@ -20,7 +20,11 @@ func init() {
|
|||||||
func(httprouter.Params, []byte) (interface{}, error) {
|
func(httprouter.Params, []byte) (interface{}, error) {
|
||||||
return bindingTeams()
|
return bindingTeams()
|
||||||
}))
|
}))
|
||||||
router.GET("/api/teams-nginx-members", apiHandler(
|
router.GET("/api/teams-nginx", apiHandler(
|
||||||
|
func(httprouter.Params, []byte) (interface{}, error) {
|
||||||
|
return nginxGenTeams()
|
||||||
|
}))
|
||||||
|
router.GET("/api/teams-members-nginx", apiHandler(
|
||||||
func(httprouter.Params, []byte) (interface{}, error) {
|
func(httprouter.Params, []byte) (interface{}, error) {
|
||||||
return nginxGenMember()
|
return nginxGenMember()
|
||||||
}))
|
}))
|
||||||
@ -86,6 +90,19 @@ func init() {
|
|||||||
router.PUT("/api/teams/:tid/members", apiHandler(teamHandler(setTeamMember)))
|
router.PUT("/api/teams/:tid/members", apiHandler(teamHandler(setTeamMember)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func nginxGenTeams() (string, error) {
|
||||||
|
if teams, err := fic.GetTeams(); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else {
|
||||||
|
ret := ""
|
||||||
|
for _, team := range teams {
|
||||||
|
ret += fmt.Sprintf(" if ($remote_user = \"%s\") { set $team \"%d\"; }\n", strings.ToLower(team.Name), team.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func nginxGenMember() (string, error) {
|
func nginxGenMember() (string, error) {
|
||||||
if teams, err := fic.GetTeams(); err != nil {
|
if teams, err := fic.GetTeams(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
Loading…
Reference in New Issue
Block a user