U
    e                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 zd d	l
Z
W n ek
r   d	Z
Y nX zd d	lZW n ek
r   d	ZY nX G d
d deZG dd deZd	S )    )Any)FileResponse)HTMLResponse)JSONResponse)PlainTextResponse)RedirectResponse)Response)StreamingResponseNc                   @   s    e Zd ZdZeedddZdS )UJSONResponsez
    JSON response using the high-performance ujson library to serialize data to JSON.

    Read more about it in the
    [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
    contentreturnc                 C   s$   t d k	stdt j|dddS )Nz,ujson must be installed to use UJSONResponseF)ensure_asciizutf-8)ujsonAssertionErrordumpsencodeselfr    r   5/tmp/pip-unpacked-wheel-8a3sx6sf/fastapi/responses.pyrender   s    zUJSONResponse.renderN__name__
__module____qualname____doc__r   bytesr   r   r   r   r   r
      s   r
   c                   @   s    e Zd ZdZeedddZdS )ORJSONResponsez
    JSON response using the high-performance orjson library to serialize data to JSON.

    Read more about it in the
    [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
    r   c                 C   s&   t d k	stdt j|t jt jB dS )Nz.orjson must be installed to use ORJSONResponse)option)orjsonr   r   ZOPT_NON_STR_KEYSZOPT_SERIALIZE_NUMPYr   r   r   r   r   ,   s
     
zORJSONResponse.renderNr   r   r   r   r   r   $   s   r   )typingr   Zstarlette.responsesr   r   r   r   r   r   r	   r   ImportErrorr    r
   r   r   r   r   r   <module>   s"   

