Add simple server creation

This commit is contained in:
Miguel de la Cruz 2023-06-30 10:33:25 +02:00
parent c617fe2505
commit acac38d1f6
2 changed files with 20 additions and 2 deletions

View file

@ -1,11 +1,27 @@
package server
import (
"fmt"
"git.ctrlz.es/mgdelacroix/birthdaybot/model"
"git.ctrlz.es/mgdelacroix/birthdaybot/parser"
)
type Server struct{}
type Server struct {
config *model.Config
birthdays []*model.Birthday
}
func New(config *model.Config) (*Server, error) {
return nil, nil
birthdays, err := parser.ParseCSV(config.BirthdayFile)
if err != nil {
return nil, fmt.Errorf("cannot parse CSV file %s: %w", config.BirthdayFile, err)
}
server := &Server{
config: config,
birthdays: birthdays,
}
return server, nil
}