| 名称 | 链接 | 备注 |
| :-- | :-- | :-- |
| 项目主页 | [https://github.com/zq2599/blog_demos](
) | 该项目在GitHub上的主页 |
| git仓库地址(https) | [https://github.com/zq2599/blog_demos.git](
) | 该项目源码的仓库地址,https协议 |
| git仓库地址(ssh) | git@github.com:zq2599/blog_demos.git | 该项目源码的仓库地址,ssh协议 |
这个git项目中有多个文件夹,本章的两个应用分别在webdemo和k8sgatewaydemo文件夹下;
下图红框中是webdemo应用的源码:
下图红框中是k8sgatewaydemo应用的源码:
下面是详细的编码过程;
[](
)开发webdemo
webdemo是个极其普通的spring boot应用,和SpringCloud没有任何关系;
- webdemo提供一个http接口,将请求header中名为extendtag的参数返回给请求方,controller类如下:
@RestController
@RequestMapping("/hello")
public class HelloController {
@RequestMapping(value = “time”, method = RequestMethod.GET)
public String hello(HttpServletRequest request){
return "hello, "
-
new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(new Date())
-
“, extendtag [”
-
request.getHeader(“extendtag”)
-
“]”;
}
}
- 启动类WebdemoApplication.java:
@SpringBootApplication
public class WebdemoApplication {
public static void main(Strin