完善部分内容

This commit is contained in:
dragon
2025-01-06 17:31:18 +08:00
parent 246bf13a6c
commit bb8966521c
5 changed files with 117 additions and 47 deletions

View File

@@ -15,6 +15,8 @@ type ServerOptions struct {
Cache utils.Cache
MaxCacheSize int
HttpClient *http.Client
}
func DefaultOptions(domain string) ServerOptions {
@@ -24,22 +26,25 @@ func DefaultOptions(domain string) ServerOptions {
Config: configMemory,
Cache: utils.NewCacheMemory(1024*1024*10, int(memory.FreeMemory()/3*2)),
MaxCacheSize: 1024 * 1024 * 10,
HttpClient: http.DefaultClient,
}
}
type Server struct {
backend core.Backend
meta *core.ServerMeta
options *ServerOptions
}
func NewPageServer(backend core.Backend, options ServerOptions) *Server {
backend = core.NewCacheBackend(backend, options.Config, time.Minute)
return &Server{
backend: core.NewCacheBackend(backend, options.Config, time.Minute),
meta: core.NewServerMeta(options.HttpClient, backend, options.Config, time.Minute),
options: &options,
}
}
func (s *Server) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
}
func (s *Server) Close() error {