51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
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)
|
|
}
|