blob: 6b861590c9965d4e5f65b247dd7f2697993ef8b9 (
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 (
"database/sql"
"html/template"
"net/http"
"github.com/go-chi/chi/v5"
"gitlab.com/alexkavon/newsstand/src/conf"
)
type Server struct {
Router *chi.Mux
Db *sql.DB
Config *conf.Conf
Templates map[string]*template.Template
}
func NewServer(config *conf.Conf, router *chi.Mux, db *sql.DB) *Server {
return &Server{
Router: router,
Db: db,
Config: config,
Templates: buildTemplates("my/path", "my/other/path"),
}
}
func (s *Server) Serve() {
http.ListenAndServe(":"+s.Config.Server.Port, s.Router)
}
|