All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.web.ReactiveHttpContextAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.web;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.WebFluxConfigurer;

@SpringBootConfiguration
@ConditionalOnWebApplication(type = Type.REACTIVE)
@ConditionalOnClass(value = {org.springframework.web.server.WebHandler.class, org.springframework.web.reactive.DispatcherHandler.class})
public class ReactiveHttpContextAutoConfiguration implements WebFluxConfigurer {

    private final HttpContextProperties httpContextProperties;

    public ReactiveHttpContextAutoConfiguration(HttpContextProperties httpContextProperties) {
        this.httpContextProperties = httpContextProperties;
    }

    @Override
    public void configurePathMatching(org.springframework.web.reactive.config.PathMatchConfigurer configurer) {
        /*请求路径添加统一前缀*/
        String basePath = httpContextProperties.getBasePath();
        configurer.addPathPrefix(basePath, c -> (c.isAnnotationPresent(Controller.class) || c.isAnnotationPresent(RestController.class)));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy