chore: fix merge conflicts

This commit is contained in:
Denis Gukov 2020-12-01 22:30:26 +05:00
commit 400d2f6933
3 changed files with 11 additions and 7 deletions

View File

@ -97,7 +97,7 @@ func Route() *mux.Router {
tokenAPI.Path("/tokens").HandlerFunc(createAPIToken).Methods("POST")
tokenAPI.HandleFunc("/tokens/{token_id}", expireAPIToken).Methods("DELETE")
userAPI := authenticatedAPI.PathPrefix("/users/{user_id}").Subrouter()
userAPI := authenticatedAPI.Path("/users/{user_id}").Subrouter()
userAPI.Use(getUserMiddleware)
userAPI.Methods("GET", "HEAD").HandlerFunc(getUser)
@ -139,9 +139,8 @@ func Route() *mux.Router {
projectUserAPI.Path("/templates").HandlerFunc(projects.GetTemplates).Methods("GET", "HEAD")
projectUserAPI.Path("/templates").HandlerFunc(projects.AddTemplate).Methods("POST")
projectAdminAPI := authenticatedAPI.PathPrefix("/project/{project_id}").Subrouter()
projectAdminAPI := authenticatedAPI.Path("/project/{project_id}").Subrouter()
projectAdminAPI.Use(projects.ProjectMiddleware, projects.MustBeAdmin)
projectAdminAPI.Methods("PUT").HandlerFunc(projects.UpdateProject)
projectAdminAPI.Methods("DELETE").HandlerFunc(projects.DeleteProject)
@ -149,7 +148,7 @@ func Route() *mux.Router {
projectAdminUsersAPI.Use(projects.ProjectMiddleware, projects.MustBeAdmin)
projectAdminUsersAPI.Path("/users").HandlerFunc(projects.AddUser).Methods("POST")
projectUserManagement := projectAdminAPI.PathPrefix("/users").Subrouter()
projectUserManagement := projectAdminUsersAPI.PathPrefix("/users").Subrouter()
projectUserManagement.Use(projects.UserMiddleware)
projectUserManagement.HandleFunc("/{user_id}", projects.GetUsers).Methods("GET", "HEAD")
@ -157,7 +156,7 @@ func Route() *mux.Router {
projectUserManagement.HandleFunc("/{user_id}/admin", projects.MakeUserAdmin).Methods("DELETE")
projectUserManagement.HandleFunc("/{user_id}", projects.RemoveUser).Methods("DELETE")
projectKeyManagement := projectAdminAPI.PathPrefix("/keys").Subrouter()
projectKeyManagement := projectAdminUsersAPI.PathPrefix("/keys").Subrouter()
projectKeyManagement.Use(projects.KeyMiddleware)
projectKeyManagement.HandleFunc("/{key_id}", projects.GetKeys).Methods("GET", "HEAD")

View File

@ -39,7 +39,8 @@ func addUser(w http.ResponseWriter, r *http.Request) {
user.Created = db.GetParsedTime(time.Now())
if err := db.Sql.Insert(&user); err != nil {
panic(err)
log.Warn(editor.Username + " is not created: " + err.Error())
w.WriteHeader(http.StatusBadRequest)
}
util.WriteJSON(w, http.StatusCreated, user)

View File

@ -101,7 +101,11 @@ func createDb() error {
return err
}
db.Exec("create database " + cfg.DbName)
_, err = db.Exec("create database " + cfg.DbName)
if err != nil {
log.Warn(err.Error())
}
return nil
}