api

command module
v0.0.0-...-cce9f1c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

api

HTTP API for Hungarofit evaluator

Based on chi and huma

Usage
Help

Navigating to /docs shows the OpenAPI documentation.

docker run ghcr.io/hungarofit/api:latest -h
Usage:
  api [flags]

Flags:
  -h, --help                        help for api
  -H, --host string                  (default "0.0.0.0")
  -P, --port int                     (default 8080)
  -t, --shutdown-timeout duration    (default 10s)
Basic
docker run -p 8080:8080 \
    ghcr.io/hungarofit/api:latest
Options from environment
docker run -p 8080:8080 \
    -e SERVICE_HOST=0.0.0.0 \
    -e SERVICE_PORT=8080 \
    -e SERVICE_SHUTDOWN_TIMEOUT=10s \
    ghcr.io/hungarofit/api:latest
Options from arguments
docker run -p 8080:8080 \
    ghcr.io/hungarofit/api:latest \
    --host=0.0.0.0 \
    --port=8080 \
    --shutdown-timeout=10s
Example requests
Hungarofit
{
  "challenge": "hfit6",
  "age": 24,
  "gender": "female",
  "exercises": [
    {
      "name": "aerob-swim-12min",
      "result": 500
    },
    {
      "name": "jump",
      "result": 1.92
    },
    {
      "name": "pushup",
      "result": 20
    },
    {
      "name": "situp",
      "result": 80
    },
    {
      "name": "torso",
      "result": 80
    },
    {
      "name": "throwdouble",
      "result": 1.92
    },
    {
      "name": "throwsingle",
      "result": 11.1
    }
  ]
}
Hungarofit Mini
{
  "challenge": "hfit4",
  "age": 24,
  "gender": "female",
  "exercises": [
    {
      "name": "aerob-swim-12min",
      "result": 500
    },
    {
      "name": "jump",
      "result": 1.92
    },
    {
      "name": "pushup",
      "result": 20
    },
    {
      "name": "situp",
      "result": 80
    },
    {
      "name": "torso",
      "result": 80
    }
  ]
}
Example response
{
  "$schema": "http://localhost:8080/schemas/EvaluateOutputBody.json",
  "total": 73,
  "total_max": 140,
  "exercises": {
    "jump": {
      "score": 11,
      "score_max": 21
    },
    "pushup": {
      "score": 9,
      "score_max": 14
    },
    "situp": {
      "score": 7,
      "score_max": 14
    },
    "swim-12min": {
      "score": 39,
      "score_max": 77
    },
    "torso": {
      "score": 7,
      "score_max": 14
    }
  }
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL