43 lines
844 B
Go
43 lines
844 B
Go
package controllers
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/NothAmor/SourceTraceFront/common"
|
|
"github.com/NothAmor/SourceTraceFront/proto"
|
|
)
|
|
|
|
func Index(c *gin.Context) {
|
|
c.HTML(200, "index.html", nil)
|
|
}
|
|
|
|
func Search(c *gin.Context) {
|
|
args := proto.Args{
|
|
Keyword: c.Query("keyword"),
|
|
}
|
|
reply := proto.Resp{}
|
|
|
|
err := common.RPC.Call(context.Background(), "Search", args, &reply)
|
|
if err != nil {
|
|
log.Printf("failed to call: %v", err)
|
|
return
|
|
}
|
|
|
|
username, _ := c.Cookie("username")
|
|
role, _ := c.Cookie("role")
|
|
|
|
c.HTML(200, "search.tpl", gin.H{
|
|
"title": reply.Title,
|
|
"time": reply.ReqTime,
|
|
"values": reply.Values,
|
|
"keyword": reply.Keyword,
|
|
"N": 650000,
|
|
"latency": reply.Latency,
|
|
"username": username,
|
|
"role": role,
|
|
})
|
|
}
|