Exemplary RESTFul API built with go, gin, gorm. Contribute to zacscoding/gin-rest-api-example development by creating an account on GitHub.
Gin REST API Example gingin-frameworkgin-swaggergin-restful-apigin-mongogin-mongo-driver UpdatedAug 4, 2019 Go Nicehouse is an open source distributed property management service platform based on Apache Dubbo-Go. golangmariadbgingormgin-swaggerdubbo-goprotoc-gen-validatekratos-layout ...
只要API程序遵循了REST风格,那就可以称其为RESTful API。目前在前后端分离的架构中,前后端基本都是通过RESTful API来进行交互。例如,我们现在要编写一个管理书籍的系统,我们可以查询对一本书进行查询、创建、更新和删除等操作,我们在编写程序的时候就要设计客户端浏览器与我们Web服务端交互的方式和路径。按照经验我们通...
Radix tree based routing, small memory foot print. No reflection. Predictable API performance. Middleware support An incoming HTTP request can be handled by a chain of middleware and the final action. For example: Logger, Authorization, GZIP and finally post a message in the DB. ...
Gin 源码地址https://github.com/gin-gonic/gin Gin是目前使用最广泛、最快的全功能web框架之一,采用Go语言(Golang)编写HTTP 服务,与它类似如martini-like API ,但Gin性能更好,基于httprouter其速度快了40倍。 Gin是一种用于构建Web应用程序的Go语言框架,具有高性能、易于使用、轻量级和灵活的特点。 Gin提供了许...
go mod init go-rest-api go-rest-api 就是项目名称,一般我们自己的项目,类似这样命令就可以了,如果是开源库,你可以在前面加上域名。 比如:github.com/gin-gonic/gin 或者用你公司的域名,加上项目名,比如example.com/go-rest-api 这条初始化命令就生成了一个文件,如下: ...
go get -u github.com/gin-gonic/gin 返回一个 json 的路由: package mainimport ( "github.com/gin-gonic/gin" "net/http")func main() { r := gin.Default() r.GET("/someJson", func(c *gin.Context) { data := map[string]interface{}{ "lang": "go lang", "tag": "", } c.JSON...
$ go get -u github.com/gin-gonic/gin Import it in your code: import "github.com/gin-gonic/gin" (Optional) Import net/http. This is required for example if using constants such as http.StatusOK.import "net/http" Quick start# assume the following codes in example.go file $ cat ...
gRPC 服务映射为 REST API,需要使用 grpc-gateway 来生成对应的代码。grpc-gateway 是protoc的一个插件。查看的安装方式参考代码仓库grpc-gateway的文档,安装完之后检查$GOBIN目录确认protoc-gen-grpc-gateway文件能够被找到。 其次,由于引用了google.api.http这个注解,需要将googleapi仓库中相关的几个文件下载到本地。
packagemainimport("github.com/gin-gonic/gin""net/http")funcmain(){r:=gin.Default()v1:=r.Group("/api/v1")v1.GET("/getUser",func(c*gin.Context){c.JSON(http.StatusOK,gin.H{"name":"golang","id":"1",})})r.Run(":8000")}复制代码 ...