aboutsummaryrefslogtreecommitdiff
path: root/src/server/router.go
blob: 6b33a7d29e8602e2650791c3b9d571d082aafb69 (plain)
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 server

import (
	"net/http"

	"github.com/go-chi/chi/v5"
	"github.com/go-chi/chi/v5/middleware"
	"gitlab.com/alexkavon/newsstand/src/conf"
	"gitlab.com/alexkavon/newsstand/src/sessions"
)

type HandlerFunc func(s *Server) http.HandlerFunc

type Route struct {
	Name         string
	Method       string
	Path         string
	AuthRequired bool
	HandlerFunc  HandlerFunc
	Middlewares  []func(http.Handler) http.Handler
}

type Routes []Route

func NewRouter(config *conf.Conf) *chi.Mux {
	r := chi.NewRouter()
	r.Use(middleware.Logger)
	r.Use(sessions.SetSession)
	return r
}