method.additional.header
- API requires additional
header
method.additional.header={name: "Authorization",value: "",desc: "authenticationToken",required:true, example:""}
- Define the following annotation:
package com.itangcent.common.annotation;
@Documented
@Retention(RUNTIME)
@Target({TYPE, METHOD})
public @interface Public {
}
method.additional.header[!@com.itangcent.common.annotation.Public]={name: "Authorization",value: "",desc: "authenticationToken",required:true, example:""}
method.additional.header[groovy:!it.hasAnn("com.itangcent.common.annotation.Public")]={name: "Authorization",value: "",desc: "authenticationToken",required:true, example:""}
demo
@RestController
@RequestMapping(value = "mock")
public class MockCtrl {
@Public
@GetMapping("/apiWithoutToken")
public Result<String> apiWithoutToken() {
return Result.success("no token");
}
@GetMapping("/apiWithToken")
public Result<String> apiWithToken() {
return Result.success("wow,you got a token");
}
}