add comments for constructors and fix typo

This commit is contained in:
Pascal Fischer
2023-02-28 15:46:08 +01:00
parent 9d7b515b26
commit c26cd3b9fe
9 changed files with 27 additions and 22 deletions

View File

@@ -14,13 +14,14 @@ import (
"github.com/netbirdio/netbird/management/server/jwtclaims"
)
type UserHandler struct {
type UsersHandler struct {
accountManager server.AccountManager
claimsExtractor *jwtclaims.ClaimsExtractor
}
func NewUserHandler(accountManager server.AccountManager, authCfg AuthCfg) *UserHandler {
return &UserHandler{
// NewUsersHandler creates a new UsersHandler HTTP handler
func NewUsersHandler(accountManager server.AccountManager, authCfg AuthCfg) *UsersHandler {
return &UsersHandler{
accountManager: accountManager,
claimsExtractor: jwtclaims.NewClaimsExtractor(
jwtclaims.WithAudience(authCfg.Audience),
@@ -30,7 +31,7 @@ func NewUserHandler(accountManager server.AccountManager, authCfg AuthCfg) *User
}
// UpdateUser is a PUT requests to update User data
func (h *UserHandler) UpdateUser(w http.ResponseWriter, r *http.Request) {
func (h *UsersHandler) UpdateUser(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPut {
util.WriteErrorResponse("wrong HTTP method", http.StatusMethodNotAllowed, w)
return
@@ -76,7 +77,7 @@ func (h *UserHandler) UpdateUser(w http.ResponseWriter, r *http.Request) {
}
// CreateUser creates a User in the system with a status "invited" (effectively this is a user invite).
func (h *UserHandler) CreateUser(w http.ResponseWriter, r *http.Request) {
func (h *UsersHandler) CreateUser(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
util.WriteErrorResponse("wrong HTTP method", http.StatusMethodNotAllowed, w)
return
@@ -116,7 +117,7 @@ func (h *UserHandler) CreateUser(w http.ResponseWriter, r *http.Request) {
// GetAllUsers returns a list of users of the account this user belongs to.
// It also gathers additional user data (like email and name) from the IDP manager.
func (h *UserHandler) GetAllUsers(w http.ResponseWriter, r *http.Request) {
func (h *UsersHandler) GetAllUsers(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
util.WriteErrorResponse("wrong HTTP method", http.StatusMethodNotAllowed, w)
return