| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package cn.exlive.exbooter.configure;
- import org.apache.commons.lang.StringUtils;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Optional;
- import java.util.Set;
- import javax.validation.constraints.NotBlank;
- import lombok.Getter;
- import lombok.Setter;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.boot.context.properties.ConfigurationProperties;
- import org.springframework.context.annotation.Configuration;
- /**
- * <pre>
- *
- * Created by zhenqin.
- * User: zhenqin
- * Date: 2022/4/25
- * Time: 下午7:12
- *
- * </pre>
- *
- * @author zhenqin
- */
- @Slf4j
- @Setter
- @Getter
- @Configuration
- @ConfigurationProperties(prefix = "exbooter")
- public class ApiRouteProperties {
- /**
- * 绑定的 tasks
- */
- Map<String, ApiRoute> routers;
- /**
- * 排除的地址
- */
- String excludePatterns = "";
- /**
- * 代理的总路由,这里默认是 /, 实际在 DDH 中访问是 /jdh/
- */
- String servletPath = "/";
- public ApiRouteProperties() {
- }
- @NotBlank
- public String getServletPath() {
- return Optional.ofNullable(StringUtils.trimToNull(servletPath)).orElse("/");
- }
- /**
- * 返回所有的 task Name
- * @return
- */
- public Set<String> getAllRouters() {
- if (routers == null) {
- routers = new HashMap<>();
- }
- return routers.keySet();
- }
- public Map<String, ApiRoute> getRouters() {
- getAllRouters();
- return routers;
- }
- }
|