package server

import (
	"embed"
	"errors"
)

type options struct {
	port      *int
	fs        *embed.FS
	debug     *bool
	secretKey *string
	origins   []string
}

type Option func(*options) error

func WithPort(port int) Option {
	return func(o *options) error {
		if port <= 0 {
			return errors.New("port should be positive")
		}
		o.port = &port
		return nil
	}
}

func WithFileSystem(fs embed.FS) Option {
	return func(o *options) error {
		o.fs = &fs
		return nil
	}
}

func WithDebug(debug bool) Option {
	return func(o *options) error {
		o.debug = &debug
		return nil
	}
}

func WithSecretKey(secretKey string) Option {
	return func(o *options) error {
		o.secretKey = &secretKey
		return nil
	}
}

func WithOrigins(origins []string) Option {
	return func(o *options) error {
		o.origins = origins
		return nil
	}
}
