认证相关路由
-
注册用户
curl -X POST http://localhost:8080/auth/register \ -H "Content-Type: application/json" \ -d '{"username": "testuser", "password": "testpass", "email": "test@example.com"}'
-
登录用户
curl -X POST http://localhost:8080/auth/login \ -H "Content-Type: application/json" \ -d '{"username": "testuser", "password": "testpass"}'
需要认证的路由
假设登录后返回的token为your_jwt_token_here
。
用户管理
-
获取所有用户
curl -X GET http://localhost:8080/api/users \ -H "Authorization: Bearer your_jwt_token_here"
-
获取单个用户
curl -X GET http://localhost:8080/api/users/1 \ -H "Authorization: Bearer your_jwt_token_here"
-
更新用户
curl -X PUT http://localhost:8080/api/users/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_jwt_token_here" \ -d '{"name": "updated_name", "email": "updated_email@example.com"}'
-
删除用户
curl -X DELETE http://localhost:8080/api/users/1 \ -H "Authorization: Bearer your_jwt_token_here"
角色管理
-
创建新角色
curl -X POST http://localhost:8080/api/roles \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_jwt_token_here" \ -d '{"name": "admin", "description": "Administrator role"}'
-
获取所有角色
curl -X GET http://localhost:8080/api/roles \ -H "Authorization: Bearer your_jwt_token_here"
-
获取单个角色
curl -X GET http://localhost:8080/api/roles/1 \ -H "Authorization: Bearer your_jwt_token_here"
-
更新角色
curl -X PUT http://localhost:8080/api/roles/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_jwt_token_here" \ -d '{"name": "updated_role_name", "description": "Updated description"}'
-
删除角色
curl -X DELETE http://localhost:8080/api/roles/1 \ -H "Authorization: Bearer your_jwt_token_here"
权限管理
-
创建新权限
curl -X POST http://localhost:8080/api/permissions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_jwt_token_here" \ -d '{"name": "create_user", "description": "Create user permission", "resource": "user", "action": "create"}'
-
获取所有权限
curl -X GET http://localhost:8080/api/permissions \ -H "Authorization: Bearer your_jwt_token_here"
-
获取单个权限
curl -X GET http://localhost:8080/api/permissions/1 \ -H "Authorization: Bearer your_jwt_token_here"
-
更新权限
curl -X PUT http://localhost:8080/api/permissions/1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_jwt_token_here" \ -d '{"name": "updated_permission_name", "description": "Updated description", "resource": "user", "action": "update"}'
-
删除权限
curl -X DELETE http://localhost:8080/api/permissions/1 \ -H "Authorization: Bearer your_jwt_token_here"
Description
Languages
Go
95.8%
Shell
4.2%