Skip to content

Commit 45b9570

Browse files
committed
add docs. fix output of /version API endpoint
1 parent 9884d17 commit 45b9570

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

docs/content/api/blip.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,14 @@ Returns the Blip version (same as [`--version`]({{< ref "/config/blip#--version"
6060
"v1.0.75"
6161
```
6262

63-
Response encoding is text (string).
63+
## GET /debug
64+
65+
Toggles debug logging.
66+
67+
*Response*
68+
69+
```json
70+
{"debugging":true}
71+
```
72+
73+

docs/content/config/blip.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ In this case, Blip tries to auto-detect a local MySQL instance, which is useful
5555

5656
Print debug to STDERR.
5757

58+
You can also toggle debug logging by sending a request to the `/debug` [API endpoint]({{< ref "/api" >}}) or by sending the `SIGUSR1` signal to the Blip process.
59+
5860
### `--help`
5961

6062
Print help and exit.

docs/content/config/logging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Start `blip` with the [`--log`]({{< ref "blip#--log" >}}) option to print info e
77

88
<p class="note">
99
<a href="blip#--debug">Debug</a> info is printed to <code>STDERR</code>.
10+
You can also toggle debug logging by sending a request to the `/debug` [API endpoint]({{< ref "/api" >}}) or by sending the `SIGUSR1` signal to the Blip process.
1011
</p>
1112

1213
This is _pseudo-logging_ because there is no traditional log printing, only events that are printed by default.

server/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ func (api *API) registered(w http.ResponseWriter, r *http.Request) {
125125

126126
func (api *API) version(w http.ResponseWriter, r *http.Request) {
127127
blip.Debug("%v", r)
128-
w.Write([]byte(blip.VERSION))
128+
json.NewEncoder(w).Encode(blip.VERSION)
129129
}
130130

131131
func (api *API) debug(w http.ResponseWriter, r *http.Request) {
132132
blip.Debug("%v", r)
133133
blip.Debugging = !blip.Debugging
134-
w.Write([]byte(fmt.Sprintf("Debugging: %t", blip.Debugging)))
134+
json.NewEncoder(w).Encode(map[string]bool{"debugging": blip.Debugging})
135135
}
136136

137137
// --------------------------------------------------------------------------

0 commit comments

Comments
 (0)