interceptor

Uploading a large file (>1GB) to grails3

吃可爱长大的小学妹 提交于 2021-02-10 19:42:29
问题 Uploading a large file (>1GB) to a grails, I only need to access it via stream, no need to save the entire file to disk or RAM. However how can I access the upload stream? I tried with an Interceptor: class UploadLargeFileInterceptor { int order = HIGHEST_PRECEDENCE UploadLargeFileInterceptor() { match(controller:"apiv2", action:"uploadLarge") } boolean before() { log.error('before') log.error(request.getInputStream().text.length() as String) true } boolean after() { log.error('after') true }

Uploading a large file (>1GB) to grails3

心不动则不痛 提交于 2021-02-10 19:41:31
问题 Uploading a large file (>1GB) to a grails, I only need to access it via stream, no need to save the entire file to disk or RAM. However how can I access the upload stream? I tried with an Interceptor: class UploadLargeFileInterceptor { int order = HIGHEST_PRECEDENCE UploadLargeFileInterceptor() { match(controller:"apiv2", action:"uploadLarge") } boolean before() { log.error('before') log.error(request.getInputStream().text.length() as String) true } boolean after() { log.error('after') true }

howto modify a webservice request using CXF interceptors with org.w3c.dom.Node

女生的网名这么多〃 提交于 2021-02-04 15:53:35
问题 Using a CXF Interceptor I'd like to append some Node to the xml being sent out to the server. I've created a interceptor (see below) that picks up the message as DOM Node, modifies it and writes it back to the message object. Unfortunately the code does not work as expected - the XML sent to the server does not contain the 'magicWord'. IMHO I'm using the wrong phase for this. So the question is: how can I modify an outgoing webservice request using the org.w3c.dom.Node syntax? package dummy;

牛X!一个注解搞定接口防刷!

蹲街弑〆低调 提交于 2021-01-29 10:56:52
说明:使用了注解的方式进行对接口防刷的功能,非常高大上,本文章仅供参考。 技术要点:springboot的基本知识,redis基本操作。 首先是写一个注解类: import java.lang.annotation.Retention; import java.lang.annotation.Target; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * @author yhq * @date 2018/9/10 15:52 */ @Retention(RUNTIME) @Target(METHOD) public @interface AccessLimit { int seconds(); int maxCount(); boolean needLogin()default true; } 接着就是在Interceptor拦截器中实现: import com.alibaba.fastjson.JSON; import com.example.demo.action.AccessLimit; import com.example.demo.redis.RedisService;

fastmybatis编写分表插件

那年仲夏 提交于 2021-01-28 17:49:31
fastmybatis 支持原生的插件,将写好的插件配置到mybatis配置文件中即可 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <plugins> <plugin interceptor="xxxxx.MyInterceptor" /> </plugins> </configuration> 这里演示编写一个分表插件 假设有4张分表,user_log0~3,记录用户的日志情况 user_log0 user_log1 user_log2 user_log3 现在需要动态查询指定到某一张表 首先生成对应的实体类,指定一张表生成,不用全部生成 /** * 表名:user_logX * %index% 占位符 */ @Table(name = "user_log%index%") public class UserLog { ... } 注意 %index% 占位符 Mapper不变 public interface UserLogMapper extends CrudMapper

Java / Kotlin / Spring Boot. How can we automatically retrieve parameter values when an exception occurs?

半腔热情 提交于 2021-01-28 11:14:59
问题 Considering that we are using Kotlin , Spring Boot , annotations and other related libraries. If we have a situation in which our code throws an exception, how could we automatically retrieve the method parameters values in the moment of that exception? Can we do this using AOP, Spring Interceptors or other techniques? We would like to have this to enrich our error messages so we could replicate the errors from where they occurred. Please note that we are searching for a solution that we don

How can we postHandle an exception in HandlerInterceptorAdapter?

两盒软妹~` 提交于 2021-01-28 09:59:59
问题 I am currently trying to implement a customized error handler for spring boot and I have done it with the following: public class ExceptionHandler extends HandlerInterceptorAdapter { public static Logger log = LoggerFactory.getLogger(LoggingInterceptor.class); public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception { try { log.info("Service {} Calling {} on {} finished with status {}",request

How can we postHandle an exception in HandlerInterceptorAdapter?

回眸只為那壹抹淺笑 提交于 2021-01-28 09:55:18
问题 I am currently trying to implement a customized error handler for spring boot and I have done it with the following: public class ExceptionHandler extends HandlerInterceptorAdapter { public static Logger log = LoggerFactory.getLogger(LoggingInterceptor.class); public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception { try { log.info("Service {} Calling {} on {} finished with status {}",request

How to import Angular HTTP interceptor only for Child module

南笙酒味 提交于 2021-01-28 05:30:59
问题 I have imported HttpClientModule in AppModule. import { HttpClientModule } from '@angular/common/http'; export const AppRoutes: Routes = [ { path: '', redirectTo: 'dashboard', pathMatch: 'full' }, { path: 'account', loadChildren: './auth/auth.module#AuthModule' }, { path: 'dashboard', loadChildren: './content/content.module#ContentModule' } ]; Once I launch site, it will redirect to dashboard module(Lazy loaded module) where i added http interceptor. import { HTTP_INTERCEPTORS } from '

Angular 6 HttpInterceptor - when getting 401 refresh the token and create the same request

℡╲_俬逩灬. 提交于 2021-01-24 07:46:04
问题 I'm using the HttpInterceptor in Angular 6, and trying to built a refresh token mechanisim: When httpClient request get's 401 status code (unauthorised) the HttpInterceptor will create a request that will refresh the token, it will update the headers of the first request and call it again with the new token. The code is working until the stage that I need to recall the original request again with the new token that got from the refresh token request. This is my code: export class