|
28 | 28 | "│")
|
29 | 29 | branch (str border " " (get-tree-branch j (count routes)))
|
30 | 30 | path (str " @|bold,green " (or (:path-prefix route) "/") "|@")
|
31 |
| - target (str " -> " (name (:service route)) "@|white @|@@|cyan " (name (:endpoint route)) "|@")] |
| 31 | + target-name (str "@|white [" (-> route :service name) "@" (-> route :endpoint-name name) "]|@") |
| 32 | + target (str " -> @|green " (get-in route [:endpoint :url]) "|@ " target-name)] |
32 | 33 | (log/info (str branch path target)))))))
|
33 | 34 |
|
34 | 35 | (defn- list-routes-table [routes]
|
35 |
| - (pprint/print-table [:name :host :path-prefix :service :endpoint :enabled] routes)) |
| 36 | + (pprint/print-table [:name :host :path-prefix :service :endpoint :url] |
| 37 | + (->> routes |
| 38 | + (map (fn [route] |
| 39 | + (-> route |
| 40 | + (assoc :endpoint (:endpoint-name route)) |
| 41 | + (assoc :url (-> route :endpoint :url)))))))) |
36 | 42 |
|
37 | 43 | (defn- list-routes [props]
|
38 | 44 | (let [module-name (prompt.config/get-module-name props)
|
|
43 | 49 | routes
|
44 | 50 | (->> (get-in module [:network :routes])
|
45 | 51 | (map (fn [[route-name route]]
|
46 |
| - (let [service (get-in module [:network :services (:service route)])] |
| 52 | + (let [service (get-in module [:network :services (:service route)]) |
| 53 | + endpoint-name (or (:endpoint route) |
| 54 | + (:default-endpoint service)) |
| 55 | + endpoint (get-in service [:endpoints endpoint-name])] |
47 | 56 | (merge route
|
48 | 57 | {:name (name route-name)
|
49 | 58 | :path-prefix (or (:path-prefix route) "/")
|
50 |
| - :endpoint (or (:endpoint route) |
51 |
| - (:default-endpoint service)) |
| 59 | + :endpoint-name endpoint-name |
| 60 | + :endpoint endpoint |
| 61 | + :url (or (:endpoint route) |
| 62 | + (:default-endpoint service)) |
52 | 63 | :enabled (get route :enabled true)}))))
|
53 | 64 | (sort (fn [a b]
|
54 | 65 | (let [a (count (:path-prefix a))
|
|
97 | 108 | :short 0
|
98 | 109 | :type :string}]
|
99 | 110 |
|
100 |
| - :runs apply-routes!} |
101 |
| - |
102 |
| - #_#_#_{:command "configure" |
103 |
| - :description "Select which routes are enabled or disabled" |
104 |
| - |
105 |
| - :opts [{:option "module" |
106 |
| - :short 0 |
107 |
| - :type :string}] |
108 |
| - |
109 |
| - :runs (fn [_])} |
110 |
| - |
111 |
| - {:command "set-service" |
112 |
| - :description "Set the service for a route" |
113 |
| - |
114 |
| - :opts [{:option "module" |
115 |
| - :short 0 |
116 |
| - :type :string}] |
117 |
| - |
118 |
| - :runs (fn [_])} |
119 |
| - |
120 |
| - {:command "set-endpoint" |
121 |
| - :description "Set the endpoint for a route" |
122 |
| - |
123 |
| - :opts [{:option "module" |
124 |
| - :short 0 |
125 |
| - :type :string}] |
126 |
| - |
127 |
| - :runs (fn [_])}]}) |
| 111 | + :runs apply-routes!}]}) |
0 commit comments