拒绝访问Spring Cloud Gateway路由的一个特定子路径

时间:2019-03-05 12:37:08

标签: spring-cloud spring-cloud-gateway

我们在后端服务之前使用Spring Cloud Gateway。我们的路线类似于以下内容:

try:
 import Tkinter
 import ttk
except:
 import tkinter as Tkinter
 import tkinter.ttk as ttk
import datetime
import beep
import os

# Creating Clock Main Class Thingy
class Clock(Tkinter.Tk):
 def __init__(self, *args, **kwargs):
  Tkinter.Tk.__init__(self, *args, **kwargs)
  self['padx']=20
  self['pady']=20
  # Creating Variables
  self.waiting_string_variable = Tkinter.IntVar()
  self.show_alarm_time = Tkinter.StringVar()
  self.show_alarm_time.set(datetime.datetime.now().ctime())
  self.alarm_delta_time = None
  self.create_first_label()
  self.create_second_box()

 # Creating Set Alarm time Showing Label
 def create_first_label(self):
  ttk.Label(self, textvariable=self.show_alarm_time, font = ("arial 20 bold")).grid(row=0, column=1, columnspan=2, padx=10,pady=10)
  return

 # Creating Keypad
 def create_second_box(self):
  ttk.Label(self, text="Wait For Seconds : ").grid(row=1, column=1, padx=10,pady=10)
  ttk.Entry(self, textvariable = self.waiting_string_variable).grid(row=1, column=2, padx=10,pady=10)
  ttk.Button(self, text="Exit", command=self.destroy).grid(row=3, column=1, padx=10,pady=10)
  ttk.Button(self, text="Set Alarm!", command=self.set_alarm_button).grid(row=3, column=2, padx=10,pady=10)
  return

 # Set Alarm Function 
 def set_alarm_button(self):
  try:
   sec = self.waiting_string_variable.get()
   self.alarm_delta_time = datetime.datetime.now()+datetime.timedelta(seconds=sec)
   self.show_alarm_time.set(self.alarm_delta_time.ctime().__str__())
  except:
   self.waiting_string_variable.set(0)
  return

 # Updating Loop
 def regular_update(self):
  self.update()
  self.update_idletasks()
  if self.alarm_delta_time:
   if datetime.datetime.now() > self.alarm_delta_time:
    beep.beep(5)


  return

# Main Function
def main():
 root = Clock(className = " Alarm Clock - Rowan S")
 while True:
  root.regular_update()
 return

# Main trigger Function
if __name__ == '__main__':
 main()

我们要拒绝访问一个特定的子路径(例如 routes: - id: foobar-service uri: lb://foobar-service predicates: - Path=/foobar/** filters: - StripPrefix=1 ),但其余路径保持打开状态。是否可以使用YAML语法来做到这一点?也许我们需要使用Fluent API来实现路由?

1 个答案:

答案 0 :(得分:1)

  routes:
    - id: foobar-baz-service
      uri: no://op
      predicates:
        - Path=/foobar/baz/**
      filters:
        - SetStatus=403
    - id: foobar-service
      uri: lb://foobar-service
      predicates:
        - Path=/foobar/**
      filters:
        - StripPrefix=1