mirror of
https://github.com/usual2970/certimate.git
synced 2025-09-08 09:21:48 +00:00
.github
.vscode
docker
internal
applicant
deployer
domain
domains
notify
pkg
repository
rest
notify.go
routes
utils
migrations
ui
.dockerignore
.editorconfig
.gitignore
.goreleaser.yml
CHANGELOG.md
CONTRIBUTING.md
CONTRIBUTING_EN.md
Dockerfile
LICENSE.md
Makefile
README.md
README_EN.md
go.mod
go.sum
main.go
nixpacks.toml
usage.gif
42 lines
797 B
Go
42 lines
797 B
Go
package rest
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/usual2970/certimate/internal/domain"
|
|
"github.com/usual2970/certimate/internal/utils/resp"
|
|
|
|
"github.com/labstack/echo/v5"
|
|
)
|
|
|
|
type NotifyService interface {
|
|
Test(ctx context.Context, req *domain.NotifyTestPushReq) error
|
|
}
|
|
|
|
type notifyHandler struct {
|
|
service NotifyService
|
|
}
|
|
|
|
func NewNotifyHandler(route *echo.Group, service NotifyService) {
|
|
handler := ¬ifyHandler{
|
|
service: service,
|
|
}
|
|
|
|
group := route.Group("/notify")
|
|
|
|
group.POST("/test", handler.test)
|
|
}
|
|
|
|
func (handler *notifyHandler) test(c echo.Context) error {
|
|
req := &domain.NotifyTestPushReq{}
|
|
if err := c.Bind(req); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := handler.service.Test(c.Request().Context(), req); err != nil {
|
|
return resp.Err(c, err)
|
|
}
|
|
|
|
return resp.Succ(c, nil)
|
|
}
|