@@ -105,7 +105,7 @@ def init_path(path, skip=0):
105105for i ,p in enumerate (path2keys (path )):
106106sp .append (p )
107107if i < skip :continue
108- pcfg ({},keys2path (* sp ))
108+ pcfg ({},keys2path (* sp ), method = 'put' )
109109
110110# %% ../nbs/00_core.ipynb 28
111111automation_path = '/apps/tls/automation'
@@ -169,26 +169,20 @@ def add_route(route):
169169# %% ../nbs/00_core.ipynb 42
170170def del_id (id ):
171171"Delete route for `id` (e.g. a host)"
172- xdelete (get_id (id ))
172+ while has_id ( id ): xdelete (get_id (id ))
173173
174174# %% ../nbs/00_core.ipynb 44
175- def add_reverse_proxy (from_host ,to_url ,st_delay = '1m' ,encode :bool = True ):
175+ def add_reverse_proxy (from_host ,to_url ,st_delay = '1m' ,compress :bool = True ):
176176"Create a reverse proxy handler"
177177if has_id (from_host ):del_id (from_host )
178178res = []
179- if encode :res .append ({"handler" :"encode" ,
180- "encodings" : {"gzip" :{},"zstd" :{}},
181- "prefer" : ["zstd" ,"gzip" ]})
182- proxy = {"handler" :"reverse_proxy" ,
183- "upstreams" : [{"dial" :to_url }]}
179+ if compress :
180+ enc = {"gzip" :{"level" :1 },"zstd" :{"level" :"fastest" }}
181+ res .append ({"handler" :"encode" ,"encodings" :enc ,"prefer" : ["zstd" ,"gzip" ]})
182+ proxy = {"handler" :"reverse_proxy" ,"upstreams" : [{"dial" :to_url }]}
184183if st_delay :proxy ["stream_close_delay" ]= st_delay
185184res .append (proxy )
186- route = {
187- "handle" :res ,
188- "match" : [{"host" : [from_host ]}],
189- "@id" :from_host ,
190- "terminal" :True
191- }
185+ route = {"handle" :res ,"match" : [{"host" : [from_host ]}],"@id" :from_host ,"terminal" :True }
192186add_route (route )
193187
194188# %% ../nbs/00_core.ipynb 48