Immutable `restructure` interface
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Bắt đầu với macro create-compojure-api được đề xuất và các điểm nhập GET, ANY, PATCH, DELETE, POST, PUT, context, routes, middleware và undocumented do nó tạo ra. Xem xét cách map tùy chọn bất biến được chuyển tiếp đến các macro này và cách các phần mở rộng của restructure được chọn. Hoàn tất khi một cấu hình bất biến, bị giới hạn có thể tạo API dự kiến mà không dựa vào multimethod restructure lớn có thể mở rộng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Instead of a big restructure multimethod that you need to manage extensions for, perhaps we can encourage more mix-and-match approaches that start to look like the kind of centralized config you'd expect from reitit.
One of the motivations is having full control and certainty over the restructure options for security purposes.
Since compojure-api is macro-based, the main obstacle here is forwarding the immutable config to the macros. This can be accomplished by a macro-generating macro.
e.g.,
(ns my-bare-bones-compojure-api
"A version of compojure-api that only supports :tags."
(:require [compojure.api.immutable :as im]
[compojure.api.meta.tags]
[clojure.set :as set]))
(def ^:private options
{:restructure {:tags compojure.api.meta.tags/extension}})
(im/create-compojure-api `options)
=>
(defmacro create-compojure-api [options]
(assert (and (seq? options)
(= 2 (count options))
(= 'quote (first options))
(qualified-symbol? (second options)))
"Options must be a quoted qualified symbol whose var contains your configuration, like: (load-api `options)")
`(let [options# ~options]
(defmacro ~'GET {:style/indent 2 :arglists '([& ~'args])} [& args#] (GET options# args#))
(defmacro ~'ANY {:style/indent 2 :arglists '([& ~'args])} [& args#] (ANY options# args#))
(defmacro ~'PATCH {:style/indent 2 :arglists '([& ~'args])} [& args#] (PATCH options# args#))
(defmacro ~'DELETE {:style/indent 2 :arglists '([& ~'args])} [& args#] (DELETE options# args#))
(defmacro ~'POST {:style/indent 2 :arglists '([& ~'args])} [& args#] (POST options# args#))
(defmacro ~'PUT {:style/indent 2 :arglists '([& ~'args])} [& args#] (PUT options# args#))
(defmacro ~'context
"Like compojure.api.core/context, except the binding vector must be empty and
no binding-style options are allowed. This is to prevent the passed routes
from being reinitialized on every request."
{:style/indent 2 :arglists '~'([path arg & args])}
[path# arg# & args#]
(context options# path# arg# args#))
(defn ~'routes
"Create a Ring handler by combining several handlers into one."
{:style/indent 2 :arglists '~'([& handlers])}
[& handlers#]
(routes options# handlers#))
(defmacro ~'middleware
"Wraps routes with given middlewares using thread-first macro.
Note that middlewares will be executed even if routes in body
do not match the request uri. Be careful with middlewares that
have side-effects."
{:style/indent 1 :arglists '~'([middleware & body-exprs])}
[middleware# & body-exprs#]
(middleware options# middleware# body-exprs#))
(defmacro ~'undocumented
"Routes without route-documentation. Can be used to wrap routes,
not satisfying compojure.api.routes/Routing -protocol."
{:arglists '~'([& handlers])}
[& handlers#]
(undocumented options# handlers#))))
- Ngôn ngữ chính
- Clojure
- Star
- 1.1k
- Fork
- 144
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của metosin/compojure-api
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
metosin/compojure-api#489 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
metosin/compojure-api#467 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
metosin/compojure-api#464 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
metosin/compojure-api#463 · 3 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
metosin/compojure-api#462 · 3 bình luận ·
Tất cả issue của metosin/compojure-api
Issue tương tự
-
to-calcit-data 查询合同漏列保留字符串选项 / Missing existing string-preserving argument in public contractĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
calcit-lang/calcit#2151 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
worker/start rejects middleware supplied as a VarCó thể đã có người làm @rajp152k đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Profiler (Remotery) leaks a socket for every connection that fails the WebSocket handshakeCó thể đã có người làm @rthery đã nhận 1 ngày trước. Đang mởtriage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
IOP nitrate needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
category:tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày