Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ Start the server on `localhost:8080` by default.
```
For further configuration, see the command-line options below.

| Flag | Description | Default |
|-----------------|--------------------------------------|-------------|
| `-H`, `--host` | Host to bind the server to | `localhost` |
| `-p`, `--port` | Port to run the server on | `8080` |
| `-a`, `--auth` | Enable bearer token authentication | `false` |
| `-t`, `--token` | Bearer token used for authentication | |
| `-h`, `--help` | Show help for the server command | |
| Flag | Description | Default |
|-------------------|--------------------------------------|-------------|
| `-H`, `--host` | Host to bind the server to | `localhost` |
| `-p`, `--port` | Port to run the server on | `8080` |
| `-a`, `--auth` | Enable bearer token authentication | `false` |
| `-t`, `--token` | Bearer token used for authentication | |
| `-m`, `--metrics` | Enable Prometheus metrics endpoint | `false` |
| `-h`, `--help` | Show help for the server command | |

Additional a systemd service file and environment file are provided in the
[contrib directory](https://github.com/tschaefer/rpinfo/tree/main/contrib) for automatic startup on boot and management of the
Expand All @@ -57,6 +58,9 @@ All endpoints return JSON-formatted data.

The complete API specification is available at `/redoc`.

Additionally, the server supports an optional `/metrics` endpoint for
Prometheus exposing clock, temperature, and voltage gauges.

## Security Notes

- If authentication is enabled, all API calls must include the `Authorization`
Expand Down
4 changes: 3 additions & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func init() {
serverCmd.Flags().StringP("host", "H", "localhost", "Host to run the server on")
serverCmd.Flags().BoolP("auth", "a", false, "Enable authentication")
serverCmd.Flags().StringP("token", "t", "", "Bearer Token for authentication")
serverCmd.Flags().BoolP("metrics", "m", false, "Enable Prometheus metrics endpoint")

rootCmd.AddCommand(serverCmd)
}
Expand All @@ -30,8 +31,9 @@ func RunServerCmd(cmd *cobra.Command, args []string) error {
host, _ := cmd.Flags().GetString("host")
auth, _ := cmd.Flags().GetBool("auth")
token, _ := cmd.Flags().GetString("token")
metrics, _ := cmd.Flags().GetBool("metrics")

server.Run(port, host, auth, token)
server.Run(port, host, auth, token, metrics)

return nil
}
Loading