-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
32 lines (24 loc) · 1.04 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"github.com/gin-gonic/gin"
controller "github.com/matheuschimelli/relaxasearch/controllers"
core "github.com/matheuschimelli/relaxasearch/core"
)
//var dataDir = flag.String("dataDir", "data", "data directory")
func main() {
router := gin.Default()
coreService := core.NewIndexService()
coreService.InitIndex("relaxasearchData")
// Handles index
router.GET("/relaxasearch/v1", controller.GETAllIndexes)
router.GET("/relaxasearch/v1/:indexName", controller.GETShowIndex)
router.POST("/relaxasearch/v1/:indexName", controller.POSTCreateIndex)
router.DELETE("/relaxasearch/v1/:indexName", controller.DELETEIndex)
// Handles Index data
router.GET("/relaxasearch/v1/:indexName/:docId", controller.GETShowDoc)
router.POST("/relaxasearch/v1/:indexName/:docId", controller.POSTUpserDoc)
router.POST("/relaxasearch/v1/:indexName/search", controller.POSTSearch)
router.GET("/relaxasearch/v1/:indexName/count", controller.GETDocCount)
router.DELETE("/relaxasearch/v1/:indexName/:docId", controller.DELETEDoc)
router.Run(":3000")
}