Skip to content

Make Server take a variadic array of Options and store config in ServerConfig #72

Description

@harrydayexe

Is your feature request related to a problem? Please describe.
Creating a server looks like the following:

cfg := config.ServerConfig{
...
}

posts := os.DirFS("...")

srv, _ := server.New(posts, cfg)

Currently, configuration in the Server is configured as follows:

  1. Server takes a options.ServerConfig which contains arrays of different Option types.
  2. The initalizer reviews each Option from each array, and runs the config step for the option
  3. In the Server struct, each config option is stored as a raw type
  4. The Server function code can then just access each config item through the server object

Describe the solution you'd like
Instead we initialize the server such as:

posts := os.DirFS("...")

srv, _ := server.New(posts, 
    config.WithBlogRoot("root/)
    ...
)

This utilizes the variadic array input for options that we have set up already.

In the Server object, this would be stored as:

type Server struct {
    ...
    config.ServerConfig
    ...
}

func New(posts fs.FS, opts ...config.ServerOptions) (*Server, Error) {}

Where ServerConfig now looks like:

type ServerConfig struct {
    BlogRoot BlogRoot
    ...
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestNew feature or improvement suggested by users

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions