forked from bruno-chavez/restedancestor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (29 loc) · 924 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
27
28
29
30
31
32
33
34
35
// Package main is the start of the API, creates all the routes and sets a handlers for each one.
package main
import (
"fmt"
"log"
"net/http"
"github.com/bruno-chavez/restedancestor/handlers"
"github.com/julienschmidt/httprouter"
)
func main() {
// initiates router
router := httprouter.New()
// lists routes
router.GET("/random", handlers.Random)
router.GET("/all", handlers.All)
router.GET("/senile", handlers.Senile)
router.GET("/search/:word", handlers.Search)
router.GET("/top", handlers.Top)
//uuid routes
router.GET("/uuid/:uuid/find", handlers.Find)
router.POST("/uuid/:uuid/like", handlers.Like)
router.POST("/uuid/:uuid/dislike", handlers.Dislike)
fmt.Println("Welcome to restedancestor, the API is running in a maddening fashion!")
fmt.Println("The Ancestor is waiting and listening on localhost:8080")
err := http.ListenAndServe(":8080", router)
if err != nil {
log.Fatal(err)
}
}