Liking cljdoc? Tell your friends :D

im.ttalk.agent.server.http

Ring 请求 / 响应的小工具(C# 里 ASP.NET 的 HttpContext 那一侧)。只认 Ring 规范(请求 map / 响应 map),不认识任何具体的 服务端 —— 同一个处理器挂在 Jetty(im.ttalk.agent.server.jetty)或别的 Ring 服务端(http-kit …)上都行。

请求就是 Ring 的请求 map(:request-method :uri :query-string :headers(小写名):body)。本模块另认几个键: :path-params 路由参数 {:id "…"}(已解码;im.ttalk.agent.server.routing 填) :im.ttalk.agent.server/body-limit 请求体上限(wrap-body-limit 填;read-body 守它) :im.ttalk.agent.server/stopping 服务端停机时完成的 CompletableFuture(宿主填;没有 = 宿主不报停机) :im.ttalk.agent.server/open-streams 宿主的「开着的长连接」表(SSE / WebSocket 登记进去,停机时逐个中止)

响应就是 Ring 的响应 map;response / json-response / text-response 造它。

Ring 请求 / 响应的小工具(C# 里 ASP.NET 的 HttpContext 那一侧)。**只认 Ring 规范**(请求 map / 响应 map),不认识任何具体的
服务端 —— 同一个处理器挂在 Jetty(im.ttalk.agent.server.jetty)或别的 Ring 服务端(http-kit …)上都行。

请求就是 Ring 的请求 map(:request-method :uri :query-string :headers(小写名):body)。本模块另认几个键:
  :path-params                  路由参数 {:id "…"}(已解码;im.ttalk.agent.server.routing 填)
  :im.ttalk.agent.server/body-limit   请求体上限(`wrap-body-limit` 填;`read-body` 守它)
  :im.ttalk.agent.server/stopping     服务端停机时完成的 CompletableFuture(宿主填;没有 = 宿主不报停机)
  :im.ttalk.agent.server/open-streams 宿主的「开着的长连接」表(SSE / WebSocket 登记进去,停机时逐个中止)

响应就是 Ring 的响应 map;`response` / `json-response` / `text-response` 造它。
raw docstring

body-too-largeclj

(body-too-large limit)

请求体超限的 ex-info(server/body-too-large;wrap-body-limit / wrap-errors 把没接住的它答成 413)。

请求体超限的 ex-info(`server/body-too-large`;`wrap-body-limit` / `wrap-errors` 把没接住的它答成 413)。
sourceraw docstring

decode-componentclj

(decode-component s plus-space?)

百分号解码(UTF-8)。plus-space? ⇒ + 当空格(查询串);路径段里 + 是字面量。坏的 % 序列 ⇒ 原样返回。

百分号解码(UTF-8)。`plus-space?` ⇒ + 当空格(查询串);路径段里 + 是字面量。坏的 % 序列 ⇒ 原样返回。
sourceraw docstring

default-max-body-bytesclj

read-body 的缺省上限:16 MiB(C# RequestBody.ReadAsStringAsync 同值)。

`read-body` 的缺省上限:16 MiB(C# RequestBody.ReadAsStringAsync 同值)。
sourceraw docstring

head?clj

(head? req)
source

(header req name)

请求头(名字大小写不敏感);Ring 把同名多个头用逗号拼成一个串。没有 ⇒ nil。

请求头(名字大小写不敏感);Ring 把同名多个头用逗号拼成一个串。没有 ⇒ nil。
sourceraw docstring

header-valuesclj

(header-values req name)

请求头按逗号拆开的各个值(Ring 已把同名多个头拼在一起)。

请求头按逗号拆开的各个值(Ring 已把同名多个头拼在一起)。
sourceraw docstring

json-responseclj

(json-response status data)
(json-response status headers data)

JSON(application/json; charset=utf-8;cheshire 编码:紧凑)。已经编好的串原样发。

JSON(application/json; charset=utf-8;cheshire 编码:紧凑)。已经编好的串原样发。
sourceraw docstring

methodclj

(method req)

大写方法名("GET")。

大写方法名("GET")。
sourceraw docstring

paramclj

(param req k)

路由参数(:id 之类)。

路由参数(`:id` 之类)。
sourceraw docstring

parse-queryclj

(parse-query raw)

原样查询串 ⇒ {名 [值 …]}(同名多值按出现顺序;没有 = 的项值为空串)。

原样查询串 ⇒ {名 [值 …]}(同名多值按出现顺序;没有 = 的项值为空串)。
sourceraw docstring

pathclj

(path req)

解码后的路径(C# 的 PathBase + Path;访问守卫的 :protected 谓词收它)。

解码后的路径(C# 的 PathBase + Path;访问守卫的 :protected 谓词收它)。
sourceraw docstring

queryclj

(query req)

{名 [值 …]}。

{名 [值 …]}。
sourceraw docstring

query-paramclj

(query-param req name)
source

query-valuesclj

(query-values req name)
source

read-bodyclj

(read-body req)
(read-body req max-bytes)

把请求体整个读成字节(上限 max-bytes,缺省 16 MiB;请求带着 wrap-body-limit 的上限时取两者小的)。 超了抛 server/body-too-large(多读一个字节就判,⛔ 不是先整个读进来再量)。没有请求体 ⇒ 空字节。

把请求体整个读成字节(上限 `max-bytes`,缺省 16 MiB;请求带着 `wrap-body-limit` 的上限时取两者小的)。
超了抛 `server/body-too-large`(多读一个字节就判,⛔ 不是先整个读进来再量)。没有请求体 ⇒ 空字节。
sourceraw docstring

read-body-stringclj

(read-body-string req)
(read-body-string req max-bytes)

同 read-body,按 UTF-8 解成串(C# RequestBody.ReadAsStringAsync)。

同 `read-body`,按 UTF-8 解成串(C# RequestBody.ReadAsStringAsync)。
sourceraw docstring

responseclj

(response status)
(response status body)
(response status headers body)

Ring 响应 map。

Ring 响应 map。
sourceraw docstring

split-pathclj

(split-path raw-path)

原样路径 ⇒ 解码后的段(空段去掉;%2F 解出来的 / 留在段里,不另切)。

原样路径 ⇒ 解码后的段(空段去掉;%2F 解出来的 / 留在段里,不另切)。
sourceraw docstring

text-responseclj

(text-response status s)

纯文本(text/plain; charset=utf-8)。

纯文本(text/plain; charset=utf-8)。
sourceraw docstring

with-headerclj

(with-header resp k v)

给响应加 / 换一个头。

给响应加 / 换一个头。
sourceraw docstring

wrap-body-limitclj

(wrap-body-limit handler limit)

请求体上限(C# KeelsonServerOptions.MaxRequestBodySize):Content-Length 超了 ⇒ 413(不进处理器); 否则把上限放进请求(read-body 守它),处理器里读超了抛的 server/body-too-large 也答 413。

请求体上限(C# KeelsonServerOptions.MaxRequestBodySize):Content-Length 超了 ⇒ 413(不进处理器);
否则把上限放进请求(`read-body` 守它),处理器里读超了抛的 `server/body-too-large` 也答 413。
sourceraw docstring

wrap-errorsclj

(wrap-errors handler)

处理器抛了:server/body-too-large ⇒ 413;别的 ⇒ 500(正文为空,⛔ 不把异常文本吐给客户端)。

处理器抛了:`server/body-too-large` ⇒ 413;别的 ⇒ 500(正文为空,⛔ 不把异常文本吐给客户端)。
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close