Skip to content

andyongh/take-a-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

take-a-rest

API server build with Hertz and ent.

Features

  • Easy to build framework HTTP RESP API server with hz
  • ORM modeling with ent.
  • Auto-reload for development with air
  • Define API with Protobuf

Getting Start

Init project

# init project
make init

# add ent. model: User
make model name=User

# add sample idl:hello for rest api
make update idl=idl/hello/hello.proto

run it

modify biz/handler/demo/hello_service.go

 resp := new(demo.HelloResp)
+ resp.RespBody = "Hello, " + req.Name

 c.JSON(consts.StatusOK, resp)
go mod tidy
make dev

Test

# expect: {"message":"pong"}
curl http://localhost:8888/ping

# expect: {"RespBody":"Hello, Andy"}
curl http://localhost:8888/hello?name=Andy

About

API server build with Hertz and entgo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published