Skip to content

InvocationContext传递的参数 服务端如何获取 #2596

@five111

Description

@five111

客户端代码如下
`
CseHttpEntity<?> entity = new CseHttpEntity<>(null);

        InvocationContext invocationContext = new InvocationContext();

        invocationContext.addContext("aaa", "bbb");

        entity.setContext(invocationContext);

        UUID uuid = UUID.randomUUID();

        System.out.println(formatter.format(new Date())+uuid);

        ResponseEntity<String> responseEntity =
                restTemplate.getForEntity(url + uuid, String.class, entity)

我想将aaa传递至服务端 服务端对应接口如下
@GetMapping("/hello/{name}")
public String sayHello(@PathVariable("name") @Length String name, InvocationContext invocationContext) throws InterruptedException {
System.out.println(invocationContext.getContext().get("aaa"));
System.out.println(formatter.format(new Date())+ " " +name);
return name+", hello";
}
`
这里无法获取到上下文的值
请问这个值该如何正确传递和获取
https://servicecomb.apache.org/references/java-chassis/zh_CN/build-provider/context-param.html
文档这里描述的不是很清晰,我服务端的写法是照着文档写的,建议文档能安招从客户端-》服务端的过程来描述

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions