Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 926 Bytes

README.md

File metadata and controls

51 lines (35 loc) · 926 Bytes

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