1
0
mirror of https://github.com/mgerb/tmail synced 2026-01-10 17:42:48 +00:00
This commit is contained in:
2018-02-01 12:01:05 -06:00
commit a6af3d11e2
9 changed files with 294 additions and 0 deletions

30
webserver/webserver.go Normal file
View File

@@ -0,0 +1,30 @@
package webserver
import (
"log"
"github.com/gin-gonic/gin"
"github.com/mgerb/tmail/db"
"github.com/mgerb/tmail/mail"
)
func Start() {
r := gin.Default()
r.GET("/api/mail", mailHander)
r.Run("0.0.0.0:8090")
}
func mailHander(c *gin.Context) {
to := c.Query("to")
var mail []mail.Mail
log.Println(to)
if to != "" {
db.Conn.Find("To", to, &mail)
} else {
db.Conn.All(&mail)
}
c.JSON(200, mail)
}