-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
42 lines (34 loc) · 1.09 KB
/
routes.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
package main
import (
"github.com/akkien/learngo-explorer-api/controllers"
"github.com/akkien/learngo-explorer-api/middlewares"
)
func (app *application) routes() {
// Use the setUserStatus middleware for every route to set a flag
// indicating whether the request was from an authenticated user or not
api := app.router.Group("/api")
// Handle the index route
api.GET("", controllers.Index)
userRoutes := api.Group("/users")
{
userRoutes.POST("/auth", controllers.Auth)
}
blockRoutes := api.Group("/blocks")
{
blockRoutes.GET("", controllers.GetBlocks)
blockRoutes.GET("/:number", controllers.GetBlock)
blockRoutes.GET("/:number/txs", controllers.GetTransactionsInBlock)
}
txRoutes := api.Group("/txs")
{
txRoutes.GET("", controllers.GetTransactions)
txRoutes.GET("/:hash", controllers.GetTransaction)
}
albumRoutes := api.Group("/albums")
{
albumRoutes.POST("", controllers.PostAlbums)
albumRoutes.GET("", controllers.GetAlbums)
albumRoutes.GET("/:id", middlewares.ValidateToken(), controllers.GetAlbumByID)
albumRoutes.DELETE("/:id", controllers.DeleteAlbumByID)
}
}