GoSimpleServe

command module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Unlicense Imports: 5 Imported by: 0

README

GitHub Workflow Status GitHub latest version GitHub Release Date GitHub go.mod Go version

GoSimpleServe

Tiny static http server container.

All files in the /static folder will be served via http.

Endpoints

Endpoint Description
/ping Always enabled and return OK
/config Enabled if /config_template.yaml is present. Syntax
/files Lists all files in the /static folder if the environment is set to ENDPOINT_FILES=true

Configuration

All environment variables are read at container start and won't refreshed afterwards.

Environment variable Type Default value Description
VERBOSE Boolean false Additional information will be logged if enabled
ENDPOINT_FILES Boolean false Enables the /files endpoint which returns a list of all files(including sub directories) in the /static folder
STATIC_CONTENT Boolean true If disabled the /config and /files endpoint won't be cached

Config Template

If a /config_template.yaml file is present the /config endpoint will be enabled.
This endpoint returns a json with values set in the container environment.

Structure

Each entry represents a field in the resulting json.
Fields require these configurations:

Field Type Description
envVariable String Environment variable name to map
defaultValue String Default value which is used if environment is not set
variableType Enum(bool,int,string,array) variable type (Default value: string)
separator String Character to separate strings if variableType is array
Example

Template:

field-name1:
  envVariable: FIELD1
  defaultValue: false
  variableType: bool
field-name2:
  envVariable: FIELD2
  defaultValue: 1
  variableType: int
field-name3:
  envVariable: FIELD3
  defaultValue: test
  variableType: string
field-name4:
  envVariable: FIELD4
  defaultValue: test1,test2,test3
  variableType: array
  separator: ","

With an environment:

  • FIELD1=true
  • FIELD3=nothing

Results in an /config response of:

{
    "field-name1": true,
    "field-name2": 1,
    "field-name3": "nothing",
    "field-name4": [
      "test1",
      "test2",
      "test3"
    ]
}

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