indieauth-server/internal/executors/serve.go
Dan Anglin 7d0336d3db
All checks were successful
CI / Tests (pull_request) Successful in 14s
CI / Style (pull_request) Successful in 9s
feat: add metadata endpoint
Add the metadata endpoint so that clients can get the server's
authorization and token endpoints.

Changes:

- Add a config object to allow administrators to configure the binding
  address, binding port and domain name.
- Add a target in the magefiles and a step in the CI workflow to run
  go vet.
- Add the Dockerfile.
- Replace the --address flag with the --config flag.
- Add the metadata endpoint to the router to return a JSON document
  containing the URLs to the metadata and token endpoints.
2024-10-15 18:22:55 +01:00

46 lines
971 B
Go

package executors
import (
"flag"
"fmt"
"codeflow.dananglin.me.uk/apollo/indieauth-server/internal/config"
"codeflow.dananglin.me.uk/apollo/indieauth-server/internal/server"
)
type serveExecutor struct {
*flag.FlagSet
configFile string
}
func executeServeCommand(args []string) error {
executorName := "serve"
executor := serveExecutor{
FlagSet: flag.NewFlagSet(executorName, flag.ExitOnError),
}
executor.StringVar(&executor.configFile, "config", "", "The path to the config file")
if err := executor.Parse(args); err != nil {
return fmt.Errorf("(%s) flag parsing error: %w", executorName, err)
}
if err := executor.execute(); err != nil {
return fmt.Errorf("(%s) execution error: %w", executorName, err)
}
return nil
}
func (e *serveExecutor) execute() error {
cfg, err := config.NewConfig(e.configFile)
if err != nil {
return fmt.Errorf("unable to load the config: %w", err)
}
srv := server.NewServer(cfg)
return srv.Serve()
}