Ver Fonte

feat: 更新若干功能

SongZihuan há 1 ano atrás
pai
commit
205c49383d
1 ficheiros alterados com 12 adições e 0 exclusões
  1. 12 0
      rest/server.go

+ 12 - 0
rest/server.go

@@ -238,6 +238,18 @@ func WithNotAllowedHandler(handler http.Handler) RunOption {
 	}
 }
 
+func WithOptionsHandler(handler http.Handler) RunOption {
+	return func(server *Server) {
+		server.router.SetOptionsHandler(handler)
+	}
+}
+
+func WithGlobalMiddleware(middleware httpx.MiddlewareFunc) RunOption {
+	return func(server *Server) {
+		server.router.SetMiddleware(middleware)
+	}
+}
+
 // WithPrefix adds group as a prefix to the route paths.
 func WithPrefix(group string) RouteOption {
 	return func(r *featuredRoutes) {