-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
43 lines (33 loc) · 942 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
36
37
38
39
40
41
42
43
package main
import (
_ "github.com/dgrijalva/jwt-go"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
_ "github.com/mattn/go-sqlite3"
"github.com/yigitnuhuz/gotodo/config"
"github.com/yigitnuhuz/gotodo/services"
)
func init() {
// Echo instance
e := echo.New()
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
// Endpoints
e.GET("/", services.Hello)
e.POST("/auth/login", services.Login)
// Token required group
r := e.Group("")
r.Use(middleware.JWT([]byte(config.JwtTokenSecret)))
r.GET("/auth/hello", services.HelloAuth)
r.GET("/todos", services.AllTodos)
r.POST("/todos", services.CreateTodo)
r.GET("/todos/:id", services.GetTodo)
r.PUT("/todos/:id/complete", services.UpdeteTodoIsComplete)
r.PUT("/todos/:id/uncomplete", services.UpdeteTodoIsUncomplete)
r.DELETE("/todos/:id", services.DeleteTodo)
// Start server
e.Logger.Fatal(e.Start(":3200"))
}
func main() {
}