JSON2FILE-GO(8)
π JSON2FILE-GO π
okay so bestie, welcome to the manual page for json2file-go, section 8 of the manual. it's a lil web server that catches JSON files for u and it's genuinely iconic. let's get into it π«Ά
β¨ NAME β¨
json2file-go β a simple web server that provides entry points to store JSON files π
β¨ SYNOPSIS β¨
json2file-go
that's it. no flags. no args. she just runs. main character energy fr fr π
β¨ DESCRIPTION β¨
so json2file-go(1) is a mini-application that runs as a Web server, and its whole job is storing the information that remote WebHooks send over in JSON format using the HTTP POST method. π
originally she was built to process GitLab and Gitea WebHooks, but ngl she can be used with other systems too.
now here's the vibe check on how auth works: to verify that a caller actually has permission to store a file, the program compares a JSON field or an HTTP HEADER against the secret it has configured for the given PATH. if the secret matches, the program then verifies that the data received is a valid JSON file β and only stores it if it is. no valid JSON, no file. periodt. β¨
the application is configured using environment variables, and she's designed to run inside a docker container or supervised with systemd if we're on a regular Linux server. πΈ
the application reads two mandatory environment variables:
J2F_BASEDIRβ the working directory of the application. it must exist before launching her, no cap.- the default value for this variable when using the systemd helper (see later, bestie) is
/var/spool/json2file-go. - if we use the application inside a container, the idea is to set the value to
/data(which is a volume in the Dockerfile) and use a volume or mount a HOST directory there. π¦
- the default value for this variable when using the systemd helper (see later, bestie) is
J2F_DIRLISTβ the list of directories in which we allow one to save files, plus an optional token that must be passed in a header or within the JSON to authorize the save operation for the file.- the variable is a string of the form:
DIR1:TOKEN1;...;DIR#:TOKEN# - there is no default for this variable β it must be set. π
- the variable is a string of the form:
other optional variables include:
J2F_SIGNATURE_HEADERSβ comma-separated list of names for the HTTP header containing the signature hash (by default the list contains the nameX-Hub-Signature)J2F_TOKEN_HEADERSβ comma-separated list of names for the HTTP header containing the token (by default the list contains the namesX-Auth-TokenandX-Gitlab-Token)J2F_TOKEN_FIELDSβ comma-separated list of names for the received JSON field that contains the token (by default we usesecret)J2F_URL_PREFIXβ service base path on URLs, the directory names are computed removing this prefixJ2F_HOSTβ IP address to bind to (default0.0.0.0)J2F_PORTβ TCP Port (80if there are no certificates,443if there are any)J2F_BINDβ Listen Address and Port (default$J2F_HOST:$J2F_PORT, if used it replaces the other two variables)J2F_CERTFILEandJ2F_KEYFILEβ public certificate and key file for TLS (if both are set it is assumed that we are using TLS and the server uses that certificate and private key)J2F_SOCKETβ UNIX Socket to listen on (has no default value; if passed, the server listens for HTTP requests on a UNIX socket, ignoring the address, port and TLS settings). this is the preferred mode when the service is accessed using NGINX as a reverse proxy. π
by default the system saves the JSON data received in the sub folder of J2F_BASEDIR that matches the requested directory name, using files with names of the form TIMESTAMP.json, where the format of TIMESTAMP is YYYYmmdd-HHMMSS.MS.json. π
while this program does nothing else, the files are usually processed by scripts launched by cron(8) or incrond(8).
to be able to work with systemd.socket(5), when the application launches it checks if the variable LISTEN_PID is set β and in that case the J2F_HOST, J2F_PORT, J2F_BIND and J2F_SOCKET are ignored, and the program listens on the first file descriptor available after stdout (the one with value 3), ignoring other descriptors if any (the daemon only listens on a file descriptor). note that in this case the J2F_CERTFILE and J2F_KEYFILE are NOT ignored (systemd can pass us a file descriptor where we should use HTTPS). π§
heads up bestie: if the program is launched without systemd and the variablesJ2F_HOST,J2F_PORT,J2F_BINDorJ2F_SOCKEThave no value, the program tries to listen on0.0.0.0:80(or0.0.0.0:443if we provide a certificate and a key file).
β¨ CONFIGURATION β¨
the binary does not read any configuration files by itself, but the packaged version includes a helper script (/usr/lib/json2file-go/json2file-go) to adjust environment variables when launching the program with systemd or other init systems (see the /usr/share/doc/json2file-go/examples directory for samples). π
the launcher script reads files from the directory /etc/json2file-go and adjusts the variables as follows:
dirlistβ file with lines of the formdir:tokenthat are passed on the variableJ2F_DIRLISTseparated by;. this file is required when using systemd. πbasedirβ value of theJ2F_BASEDIRvariable, has a default value when using systemddebugβ value of theJ2F_DEBUGvariablesignature_headersβ lines with of HTTP header names that can contain signature hashes, the values are stored separated by commas on the environment variableJ2F_SIGNATURE_HEADERStoken_headersβ lines with of HTTP header names that can contain authorization tokens, the values are stored separated by commas on the environment variableJ2F_TOKEN_HEADERStoken_fieldsβ lines with names of JSON fields that can contain authorization tokens, the values are stored separated by commas on the environment variableJ2F_TOKEN_FIELDSurl_prefixβ value of theJ2F_URL_PREFIXbindβ value of theJ2F_BINDvariablehostβ value of theJ2F_HOSTvariableportβ value of theJ2F_PORTvariablecertfileβ value of theJ2F_CERFILEvariablekeyfileβ value of theJ2F_KEYFILEvariablesocketβ value of theJ2F_SOCKETvariable
β¨ BUGS β¨
none so far... ;) ππ
(not me being obsessed with that confidence level. we love a bug-free queen.)
β¨ AUTHOR β¨
json2file was originally written by Sergio Talens-Oliag in Python using the Flask micro framework, later it was rewritten using FastAPI (another Python framework), and to make it lighter for container usage this third version in Go was born. π
β¨ SEE ALSO β¨
docker(1), systemd(1), incrond(8)
β¨ COPYING β¨
Copyright (c) 2019-2020 Sergio Talens-Oliag. Free use of this software is granted under the terms of the Apache License Version 2.0.
and that's the whole page bestie!! π this version is from 2025-06-25, and yes it's still JSON2FILE-GO(8) β the one and only. mwah, go store some JSON πβ¨π
π¦ where this page comes from
- ubuntu noble: json2file-go 1.15ubuntu0.24.04.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms