关于go:go微服务框架Kratos-连载五使用protbuf创建http服务器

一、介绍

前几张咱们曾经学了kratos的根本框架。本章咱们来深刻分析一下原理。
kratos框架之所以可能应用protbuf创立http服务器,多亏了框架自带的
protoc-gen-go-http插件。
那么咱们是否能够在其余中央应用这个插件呢,答案是能够,明天咱们就试一下。
本文章代码地址在 https://github.com/hisheng/kratos-http

1.1 筹备目录

咱们新建一个 kratos-http目录,并且go模块初始化。
创立目录:

mkdir kratos-http && cd kratos-http

go我的项目初始化:
咱们在kratos-http根目录执行一下代码

go mod init github.com/hisheng/kratos-http

1.2 装置protoc-gen-go以及http扩大protoc-gen-go-http

咱们在kratos-http根目录执行一下代码,装置扩大。

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理