-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
26 lines (21 loc) · 788 Bytes
/
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
package main
import (
"fmt"
"net/http"
"github.com/Sakthe-Balan/GoMongoDB/handlers"
)
func main() {
dir := "./dbase"
handlers.InitDB(dir)
http.HandleFunc("/write", handlers.CreateResourceHandler) // POST
http.HandleFunc("/read", handlers.ReadResourceHandler) // GET
http.HandleFunc("/readall", handlers.ReadAllResourcesHandler) // GET
http.HandleFunc("/delete", handlers.DeleteResourceHandler) // DELETE
http.HandleFunc("/deleteall", handlers.DeleteAllHandler) // DELETE
http.HandleFunc("/search", handlers.SearchHandler) // POST
http.HandleFunc("/regexsearch", handlers.RegexSearchHandler)
fmt.Println("Starting server on :6942")
if err := http.ListenAndServe(":6942", nil); err != nil {
fmt.Println("Error starting server:", err)
}
}