Use pointer receiver more offen
This commit is contained in:
parent
6999b4e728
commit
c7569b5e54
59 changed files with 688 additions and 672 deletions
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
}))
|
||||
|
||||
router.GET("/api/teams/:tid/certificates", apiHandler(teamHandler(
|
||||
func(team fic.Team, _ []byte) (interface{}, error) {
|
||||
func(team *fic.Team, _ []byte) (interface{}, error) {
|
||||
if serials, err := pki.GetTeamSerials(TeamsDir, team.Id); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
|
|
@ -84,18 +84,18 @@ func init() {
|
|||
})))
|
||||
|
||||
router.GET("/api/teams/:tid/associations", apiHandler(teamHandler(
|
||||
func(team fic.Team, _ []byte) (interface{}, error) {
|
||||
func(team *fic.Team, _ []byte) (interface{}, error) {
|
||||
return pki.GetTeamAssociations(TeamsDir, team.Id)
|
||||
})))
|
||||
router.POST("/api/teams/:tid/associations/:assoc", apiHandler(teamAssocHandler(
|
||||
func(team fic.Team, assoc string, _ []byte) (interface{}, error) {
|
||||
func(team *fic.Team, assoc string, _ []byte) (interface{}, error) {
|
||||
if err := os.Symlink(fmt.Sprintf("%d", team.Id), path.Join(TeamsDir, assoc)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return "\"" + assoc + "\"", nil
|
||||
})))
|
||||
router.DELETE("/api/teams/:tid/associations/:assoc", apiHandler(teamAssocHandler(
|
||||
func(team fic.Team, assoc string, _ []byte) (interface{}, error) {
|
||||
func(team *fic.Team, assoc string, _ []byte) (interface{}, error) {
|
||||
if err := os.Remove(path.Join(TeamsDir, assoc)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -110,11 +110,11 @@ func init() {
|
|||
router.GET("/api/certs/:certid", apiHandler(certificateHandler(getTeamP12File)))
|
||||
router.PUT("/api/certs/:certid", apiHandler(certificateHandler(updateCertificateAssociation)))
|
||||
router.DELETE("/api/certs/:certid", apiHandler(certificateHandler(
|
||||
func(cert fic.Certificate, _ []byte) (interface{}, error) { return cert.Revoke() })))
|
||||
func(cert *fic.Certificate, _ []byte) (interface{}, error) { return cert.Revoke() })))
|
||||
}
|
||||
|
||||
func genHtpasswd(ssha bool) (ret string, err error) {
|
||||
var teams []fic.Team
|
||||
var teams []*fic.Team
|
||||
teams, err = fic.GetTeams()
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -133,7 +133,7 @@ func genHtpasswd(ssha bool) (ret string, err error) {
|
|||
}
|
||||
|
||||
for _, serial := range serials {
|
||||
var cert fic.Certificate
|
||||
var cert *fic.Certificate
|
||||
cert, err = fic.GetCertificate(serial)
|
||||
if err != nil {
|
||||
// Ignore invalid/incorrect/non-existant certificates
|
||||
|
|
@ -219,7 +219,7 @@ func getCAPEM(_ httprouter.Params, _ []byte) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func getTeamP12File(cert fic.Certificate, _ []byte) (interface{}, error) {
|
||||
func getTeamP12File(cert *fic.Certificate, _ []byte) (interface{}, error) {
|
||||
// Create p12 if necessary
|
||||
if _, err := os.Stat(pki.ClientP12Path(cert.Id)); os.IsNotExist(err) {
|
||||
if err := pki.WriteP12(cert.Id, cert.Password); err != nil {
|
||||
|
|
@ -308,7 +308,7 @@ type CertUploaded struct {
|
|||
Team *int64 `json:"id_team"`
|
||||
}
|
||||
|
||||
func updateCertificateAssociation(cert fic.Certificate, body []byte) (interface{}, error) {
|
||||
func updateCertificateAssociation(cert *fic.Certificate, body []byte) (interface{}, error) {
|
||||
var uc CertUploaded
|
||||
if err := json.Unmarshal(body, &uc); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Reference in a new issue