![我可以使用什么包来描述 HTTP 请求?](https://linux22.com/image/463488/%E6%88%91%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E4%BB%80%E4%B9%88%E5%8C%85%E6%9D%A5%E6%8F%8F%E8%BF%B0%20HTTP%20%E8%AF%B7%E6%B1%82%EF%BC%9F.png)
有没有办法格式化这样的 HTTP 请求,就像使用http
markdown 时一样?
PATCH /v1/something/1234 HTTP/1.1
Host: somehost.com
Content-Type: application/json
Accept: application/json
Api-Key: supersecretkey
Content-Length: 107
{
"date": "2023-03-15 05:39",
"status": 0
}
答案1
您可以使用包minted
。Pygemtize 支持词法分析器http
。您可以使用以下命令进行检查:pygmentize -L lexers
。
\usepackage{minted}
\begin{minted}{http}
PATCH /v1/something/1234 HTTP/1.1
Host: somehost.com
Content-Type: application/json
Accept: application/json
Api-Key: supersecretkey
Content-Length: 107
\end{minted}
\begin{minted}[]{js}
{
"date": "2023-03-15 05:39",
"status": 0
}
\end{minted}