all repos

onasty @ 2cd7240

a one-time notes service

onasty/internal/transport/http/apiv1/apiv1.go(view raw)

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
package apiv1

import (
	"github.com/gin-gonic/gin"
	"github.com/olexsmir/onasty/internal/service/usersrv"
)

type APIV1 struct {
	usersrv usersrv.UserServicer
}

func NewAPIV1(us usersrv.UserServicer) *APIV1 {
	return &APIV1{
		usersrv: us,
	}
}

func (a *APIV1) Routes(r *gin.RouterGroup) {
	auth := r.Group("/auth")
	{
		auth.POST("/signup", a.signUpHandler)
		auth.POST("/signin", a.signInHandler)
		auth.POST("/refresh-tokens", a.refreshTokensHandler)

		authorized := auth.Group("/", a.authorizedMiddleware)
		{
			authorized.POST("/logout", a.logOutHandler)
		}
	}
}