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

com.yuxuan66.core.utils.web.HandlerUtils Maven / Gradle / Ivy

package com.yuxuan66.core.utils.web;

import java.util.Map;

import com.yuxuan66.core.annotaion.enums.MappingType;
import com.yuxuan66.core.constant.Constant;
import com.yuxuan66.core.handler.MappingHandler;
import com.yuxuan66.core.utils.CacheManager;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HandlerUtils {
	@SuppressWarnings("unchecked")
	public static  T getHandler() {
		String url = WebContext.getRequest().getRequestURI();
		Map mappings = CacheManager.getData(Constant.MVC_MAPPING);
		MappingHandler mappingHandler = mappings.get(url);
		if (mappingHandler == null) {
			return null;
		}
		String method = WebContext.getRequest().getMethod();
		if ("GET".equalsIgnoreCase(method) && mappingHandler.getRequestMethod() == MappingType.POST) {
			log.error("Mapping ->" + url + " is not found GET Method!");
		}else if ("POST".equalsIgnoreCase(method) && mappingHandler.getRequestMethod() == MappingType.GET) {
			log.error("Mapping ->" + url + " is not found POST Method!");
		}
		return (T) mappingHandler;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy