Skip to content

Commit

Permalink
add --footer-file flag
Browse files Browse the repository at this point in the history
like --foter but read it from a file
  • Loading branch information
chmouel committed May 28, 2024
1 parent 7453146 commit e6a6722
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ behind a proxy with the flags `--address` and `--port`.
You really want to secure that endpoint, you can generate some letsencrypt
certificate and use the `--tls-cert` and `--tls-key` flags to specify them.

If you're really lazy (and who isn't) you can just give the flag `--auto-cert` and
it will automatically generate certs. Unfortunately this require to run on
port 443 which need root and very secure. It may be better to just have [caddy](#caddy) installed in front of gosmee.
There is a lot of other flags you can use to customize the server, you can see them with `gosmee server --help`.

To use it you go to your URL and a suffix with your random ID. For example:

Expand Down
4 changes: 4 additions & 0 deletions gosmee/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ var serverFlags = []cli.Flag{
Name: "footer",
Usage: "An HTML string to show in footer for copyright and author",
},
&cli.StringFlag{
Name: "footer-file",
Usage: "An HTML file to show in footer for copyright and author",
},
&cli.StringFlag{
Name: "address",
Aliases: []string{"a"},
Expand Down
11 changes: 11 additions & 0 deletions gosmee/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ func errorIt(w http.ResponseWriter, _ *http.Request, status int, err error) {
func serve(c *cli.Context) error {
publicURL := c.String("public-url")
footer := c.String("footer")
footerFile := c.String("footer-file")
if footer != "" && footerFile != "" {
return fmt.Errorf("cannot use both --footer and --footer-file")
}
if footerFile != "" {
b, err := os.ReadFile(footerFile)
if err != nil {
return err
}
footer = string(b)
}
router := chi.NewRouter()
router.Use(middleware.RequestID)
router.Use(middleware.RealIP)
Expand Down

0 comments on commit e6a6722

Please sign in to comment.