mirror of https://github.com/tiangolo/fastapi.git
Translation completed, ready tp PR.
This commit is contained in:
parent
1e51f4dc34
commit
fb5c0e43a1
|
|
@ -1,42 +1,42 @@
|
|||
# Response Headers
|
||||
# Yanıt Başlıkları
|
||||
|
||||
## Use a `Response` parameter
|
||||
## Bir `Response` Parametresi Kullanın
|
||||
|
||||
You can declare a parameter of type `Response` in your *path operation function* (as you can do for cookies).
|
||||
*yol operasyonu fonksiyonunuzda* `Response` türünde bir parametre belirleyebilirsiniz (tıpkı çerezlerde olduğu gibi).
|
||||
|
||||
And then you can set headers in that *temporal* response object.
|
||||
Ardından *geçici* yanıt nesnesinde başlıkları belirleyebilirsiniz.
|
||||
|
||||
```Python hl_lines="1 7-8"
|
||||
{!../../../docs_src/response_headers/tutorial002.py!}
|
||||
```
|
||||
|
||||
And then you can return any object you need, as you normally would (a `dict`, a database model, etc).
|
||||
Sonunda normalde döndürdüğünüz gibi herhangi bir nesneyi döndürebilirsiniz (bir `dict`, bir veritabanı modeli, vb).
|
||||
|
||||
And if you declared a `response_model`, it will still be used to filter and convert the object you returned.
|
||||
Eğer bir `response_model` belirlediyseniz, döndürdüğünüz nesneyi filtrelemek ve dönüştürmek için kullanılacaktır.
|
||||
|
||||
**FastAPI** will use that *temporal* response to extract the headers (also cookies and status code), and will put them in the final response that contains the value you returned, filtered by any `response_model`.
|
||||
**FastAPI** bu *geçici* yanıtı başlıkları (ayrıca durum kodunu ve çerezleri) çıkarmak için kullanacak ve döndürdüğünüz değeri herhangi bir `response_model` tarafından filtreleyerek son yanıta koyacaktır.
|
||||
|
||||
You can also declare the `Response` parameter in dependencies, and set headers (and cookies) in them.
|
||||
Bağımlılıklarda da `Response` parametresini belirtebilir ve başlıkları belirleyebilirsiniz.
|
||||
|
||||
## Return a `Response` directly
|
||||
## Bir `Response`'u Doğrudan Döndürün
|
||||
|
||||
You can also add headers when you return a `Response` directly.
|
||||
Doğrudan bir `Response` döndürürken başlıklar oluşturabilirsiniz.
|
||||
|
||||
Create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank} and pass the headers as an additional parameter:
|
||||
Bunun için [Return a Response Directly](response-directly.md){.internal-link target=_blank} sayfasında açıklandığı gibi bir yanıt oluşturup başlkları ekleyin:
|
||||
|
||||
```Python hl_lines="10-12"
|
||||
{!../../../docs_src/response_headers/tutorial001.py!}
|
||||
```
|
||||
|
||||
!!! note "Technical Details"
|
||||
You could also use `from starlette.responses import Response` or `from starlette.responses import JSONResponse`.
|
||||
!!! note "Teknik Detaylar"
|
||||
Projenize dahil etmek için `from starlette.responses import Response` veya `from starlette.responses import JSONResponse` kullanabilirsiniz.
|
||||
|
||||
**FastAPI** provides the same `starlette.responses` as `fastapi.responses` just as a convenience for you, the developer. But most of the available responses come directly from Starlette.
|
||||
**FastAPI**, geliştiricilere kolaylık sağlamak amacıyla `starlette.responses`'ı `fastapi.responses` olarak sağlar. Ancak mevcut yanıtların çoğu doğrudan Starlette'den gelir. Aynı durum `status` için de geçerlidir.
|
||||
|
||||
And as the `Response` can be used frequently to set headers and cookies, **FastAPI** also provides it at `fastapi.Response`.
|
||||
`Response` sıklıkla başlıkları ve çerezleri belirlemek için kullanılabileceği için, **FastAPI** ayrıca `fastapi.Response`'ı da sağlar.
|
||||
|
||||
## Custom Headers
|
||||
## Özelleştirilmiş Başlıklar
|
||||
|
||||
Keep in mind that custom proprietary headers can be added <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">using the 'X-' prefix</a>.
|
||||
Aklınızda bulundurun ki özel başlıklar, <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">'X-' öneki kullanılarak</a> eklenmelidir.
|
||||
|
||||
But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), using the parameter `expose_headers` documented in <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlette's CORS docs</a>.
|
||||
Tarayıcıdaki bir istemcinin görüntüleyebilmesini istediğiniz özel başlıklarınız varsa, bunları <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlette'nin CORS dokümantasyonunda</a> belirtildiği gibi `expose_headers` parametresini kullanarak CORS yapılandırmalarınıza eklemeniz gerekir (daha fazlasını [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank} sayfasında okuyabilirsiniz),.
|
||||
|
|
|
|||
Loading…
Reference in New Issue