Documentation
¶
Overview ¶
SPDX-License-Identifier: Apache-2.0 Copyright © 2022 Roberto Hidalgo <nidito@un.rob.mx>
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ServerCommand = &command.Command{ Path: []string{"server"}, Summary: "Runs the http server", Description: "", Options: command.Options{ "config": { Type: "string", Default: "./config.joao.yaml", }, "db": { Type: "string", Default: "./puerta.db", }, }, Action: func(cmd *command.Command) error { config := cmd.Options["config"].ToValue().(string) db := cmd.Options["db"].ToValue().(string) data, err := os.ReadFile(config) if err != nil { return fmt.Errorf("could not read config file: %w", err) } cfg := server.ConfigDefaults(db) if err := yaml.Unmarshal(data, &cfg); err != nil { return fmt.Errorf("could not unserialize yaml at %s: %w", config, err) } logger := logrus.New() logger.SetFormatter(&logrus.JSONFormatter{DisableTimestamp: false}) router, err := server.Initialize(cfg) if err != nil { return err } logrus.Infof("Listening at %s", cfg.HTTP.Listen) return http.ListenAndServe(cfg.HTTP.Listen, router) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.