refactor: разнести пакеты и обновить валидацию
This commit is contained in:
50
mila.go
Normal file
50
mila.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package mila
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"gitea.unprism.ru/KRBL/mila/httpserver"
|
||||
"gitea.unprism.ru/KRBL/mila/protocol"
|
||||
"gitea.unprism.ru/KRBL/mila/storage"
|
||||
)
|
||||
|
||||
type ContentState = protocol.ContentState
|
||||
type Config = protocol.Config
|
||||
type Store = protocol.Store
|
||||
type Handler = httpserver.Handler
|
||||
type Option = httpserver.Option
|
||||
type MemoryStore = storage.MemoryStore
|
||||
type FileStore = storage.FileStore
|
||||
|
||||
var (
|
||||
ErrNotReady = protocol.ErrNotReady
|
||||
ErrInvalidData = protocol.ErrInvalidData
|
||||
)
|
||||
|
||||
func DefaultConfig() Config {
|
||||
return protocol.DefaultConfig()
|
||||
}
|
||||
|
||||
func Validate(cfg Config, state ContentState) error {
|
||||
return protocol.Validate(cfg, state)
|
||||
}
|
||||
|
||||
func NewHandler(cfg Config, store Store, opts ...Option) *Handler {
|
||||
return httpserver.NewHandler(cfg, store, opts...)
|
||||
}
|
||||
|
||||
func WithLogger(logger *slog.Logger) Option {
|
||||
return httpserver.WithLogger(logger)
|
||||
}
|
||||
|
||||
func WithOnSet(fn func(ContentState)) Option {
|
||||
return httpserver.WithOnSet(fn)
|
||||
}
|
||||
|
||||
func NewMemoryStore() *MemoryStore {
|
||||
return storage.NewMemoryStore()
|
||||
}
|
||||
|
||||
func NewFileStore(path string) *FileStore {
|
||||
return storage.NewFileStore(path)
|
||||
}
|
||||
Reference in New Issue
Block a user