Initial commit: conversaions, status, version
This commit is contained in:
40
server/server.go
Normal file
40
server/server.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"code.severnaya.net/kordophone-mock/v2/data"
|
||||
"code.severnaya.net/kordophone-mock/v2/model"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
version string
|
||||
conversations []model.Conversation
|
||||
}
|
||||
|
||||
func NewServer() *Server {
|
||||
return &Server{
|
||||
version: "1.0",
|
||||
conversations: []model.Conversation{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) Version() string {
|
||||
return s.version
|
||||
}
|
||||
|
||||
func (s *Server) Conversations() []model.Conversation {
|
||||
return s.conversations
|
||||
}
|
||||
|
||||
func (s *Server) AddConversation(c model.Conversation) {
|
||||
s.conversations = append(s.conversations, c)
|
||||
}
|
||||
|
||||
func (s *Server) PopulateWithTestData() {
|
||||
numConversations := 100
|
||||
cs := make([]model.Conversation, numConversations)
|
||||
for i := 0; i < numConversations; i++ {
|
||||
cs[i] = data.GenerateRandomConversation()
|
||||
}
|
||||
|
||||
s.conversations = cs
|
||||
}
|
||||
Reference in New Issue
Block a user