pub async fn get_module(__arg0: State<AppState>, __arg1: Path<i64>) -> Response
Expand description
GET /api/modules/{module_id}
Retrieves detailed information about a specific module, including assigned lecturers, tutors, and students.
§Arguments
The argument is extracted automatically from the HTTP route:
- Path parameter
module_id
: The ID of the module to retrieve.
§Returns
Returns an HTTP response indicating the result:
200 OK
with the full module details (including associated lecturers, tutors, and students) if successful.404 NOT FOUND
if no module is found with the givenmodule_id
.500 INTERNAL SERVER ERROR
if a database error occurs or if related personnel data (lecturers, tutors, or students) fails to load.
The response body is a JSON object using a standardized API response format, containing:
- Module information.
- Lists of users for each role (lecturers, tutors, students), each mapped to
UserResponse
.
§Example Response
200 OK
{
"success": true,
"data": {
"id": 1,
"code": "CS101",
"year": 2024,
"description": "Introduction to Computer Science",
"credits": 15,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z",
"lecturers": [
{
"id": 1,
"username": "lecturer1",
"email": "[email protected]",
"admin": false,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
],
"tutors": [
{
"id": 2,
"username": "tutor1",
"email": "[email protected]",
"admin": false,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
],
"students": [
{
"id": 3,
"username": "student1",
"email": "[email protected]",
"admin": false,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
]
},
"message": "Module retrieved successfully"
}
404 Not Found
{
"success": false,
"message": "Module not found"
}
500 Internal Server Error
{
"success": false,
"message": "Database error retrieving module"
}