Update code in endpoints/logout.post.py
This commit is contained in:
parent
290b504eed
commit
531bd176f2
@ -1,28 +1,15 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
users = [] # In-memory storage
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/logout")
|
||||
async def logout(request):
|
||||
async def logout():
|
||||
"""Logout endpoint"""
|
||||
if request.method != "POST":
|
||||
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
||||
|
||||
# Logout logic here
|
||||
return {
|
||||
"message": "Logout successful",
|
||||
"method": "POST",
|
||||
"_verb": "post"
|
||||
}
|
||||
```
|
||||
|
||||
This is a FastAPI endpoint that handles a POST request to the `/logout` path. It adheres to the provided rules and examples, including:
|
||||
|
||||
1. Using the `@router.post` decorator to define a POST endpoint.
|
||||
2. Checking if the request method is POST, and raising a 405 Method Not Allowed error if not.
|
||||
3. Returning a response with the required fields: `"message"`, `"method"`, and `"_verb"`.
|
||||
4. Placeholder for logout logic (e.g., invalidating session, clearing cookies, etc.).
|
||||
|
||||
Note that the actual logout functionality is not implemented here, as it would depend on the specific authentication mechanism used in the application.
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user