Skip to content

Commit

Permalink
remove graphql, using restful api with swagger doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed Oct 9, 2019
1 parent 554e45b commit f33c57c
Show file tree
Hide file tree
Showing 24 changed files with 13,453 additions and 5,672 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ build-release:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS) -o build/release/adanos-alert-linux cmd/adanos-alert/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags $(LDFLAGS) -o build/release/adanos-alert-arm cmd/adanos-alert/main.go


static-gen:
esc -pkg api -o api/static.go -prefix=dashboard/dist dashboard/dist

doc-gen:
swag init -g api/provider.go

clean:
rm -fr build/debug/adanos-alert build/release/adanos-alert*

.PHONY: run build build-release clean
.PHONY: run build build-release clean build-dashboard run-dashboard static-gen doc-gen
25 changes: 18 additions & 7 deletions api/controller/welcome.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package controller

import (
"github.com/mylxsw/container"
"github.com/mylxsw/hades"
)

type WelcomeController struct{}
type WelcomeController struct {
cc *container.Container
}

func NewWelcomeController(cc *container.Container) Controller {
return &WelcomeController{cc: cc}
}

func NewWelcomeController() *WelcomeController {
return &WelcomeController{}
func (w *WelcomeController) Register(router *hades.Router) {
router.Any("/", w.Home)
}

func (controller *WelcomeController) Register(router *hades.Router) {
router.Get("/", controller.Home)
type WelcomeMessage struct {
Version string `json:"version"`
}

func (*WelcomeController) Home(ctx *hades.WebContext, req *hades.Request) hades.HTTPResponse {
return ctx.API("0000", "hello, world", nil)
// Home 欢迎页面,API版本信息
// @Summary 欢迎页面,API版本信息
// @Success 200 {object} controller.WelcomeMessage
// @Router / [get]
func (w *WelcomeController) Home(ctx *hades.WebContext, req *hades.HttpRequest) WelcomeMessage {
return WelcomeMessage{Version: w.cc.MustGet("version").(string)}
}
15 changes: 0 additions & 15 deletions api/graphql.go

This file was deleted.

0 comments on commit f33c57c

Please sign in to comment.