Skip to content

Commit 5662c87

Browse files
committed
cli/api: 1.1.0 changes; / -> /health endpoint
1 parent f5264a1 commit 5662c87

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

api/api.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
# <https://www.gnu.org/licenses/>.
1818

1919
#* @apiTitle Hydrofabric Subsetter
20-
#* @apiDescription This is a sample server for a subsetting Cloud Native Hydrofabrics
20+
#* @apiDescription This is a REST API for subsetting cloud-native hydrofabrics.
2121
#* @apiContact list(name = "hfsubsetCLI API Support", email = "[email protected]")
2222
#* @apiLicense list(name = "GNU General Public License (GPL-3.0)", url = "https://www.gnu.org/licenses/")
23+
#* @apiVersion 1.1.0
2324

2425
logger::log_formatter(logger::formatter_glue_safe)
2526

@@ -149,9 +150,9 @@ function(req) {
149150
}
150151

151152
#* Health Check
152-
#* @head /
153+
#* @head /health
153154
function(req, res) {
154-
res$setHeader("X-HFSUBSET-API-VERSION", "1.0.0")
155+
res$setHeader("X-HFSUBSET-API-VERSION", "1.1.0")
155156
res
156157
}
157158

cli/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const USAGE string = `hfsubset - Hydrofabric Subsetter
3737
Usage:
3838
hfsubset [OPTIONS] identifiers...
3939
hfsubset (-h | --help)
40+
hfsubset -version
4041
4142
Examples:
4243
hfsubset -o ./divides_nexus.gpkg \
@@ -154,7 +155,7 @@ func outputFile(path string, r io.Reader) (int64, error) {
154155
}
155156

156157
func endpointVerify(endpoint string) (string, error) {
157-
resp, err := sendRequest("HEAD", endpoint)
158+
resp, err := sendRequest("HEAD", endpoint+"health")
158159
if err != nil {
159160
return "", err
160161
}
@@ -167,7 +168,7 @@ func endpointVerify(endpoint string) (string, error) {
167168

168169
ver := resp.Header.Get("X-HFSUBSET-API-VERSION")
169170
if ver == "" {
170-
ver = "0.1.0-alpha" // initial version, pre 0.1.0
171+
ver = "<=1.0.0" // initial version, pre 0.1.0
171172
}
172173

173174
return ver, nil
@@ -216,10 +217,16 @@ func main() {
216217
flag.BoolVar(&debug, "debug", false, "Run in debug mode")
217218
flag.BoolVar(&verify, "verify", true, "Verify that endpoint is available")
218219
flag.BoolVar(&dryRun, "dryrun", false, "Perform a dry run, only outputting the request that will be sent")
220+
version := flag.Bool("version", false, "Output the version")
219221
layers := flag.String("l", "divides,flowlines,network,nexus", "Comma-delimited list of layers to subset.")
220222
weights := flag.String("w", "", "Comma-delimited list of weights to generate over the subset.")
221223
flag.Parse()
222224

225+
if version != nil && *version {
226+
fmt.Println("hfsubset v1.1.0")
227+
return
228+
}
229+
223230
if len(flag.Args()) == 0 {
224231
flag.Usage()
225232
return

0 commit comments

Comments
 (0)