aboutsummaryrefslogtreecommitdiff
path: root/src/server/router.go
blob: 3b431198c38a98c598997803fdb4c1fcf08b3ca9 (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
	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)
	sessions.InitStore()
	r.Use(sessions.StartSession)
	return r
}