Redoing program to center around JSONRPC instead of a more REST-like API

This commit is contained in:
Ben 2025-07-28 08:10:06 -07:00
parent ed4bbeb608
commit be8936a665
Signed by: webmaster
GPG key ID: A5FCBAF34E6E8B50
15 changed files with 209 additions and 170 deletions

37
auth/auth.go Normal file
View file

@ -0,0 +1,37 @@
package auth
/* This file contains the AuthAuthConfig object and its methods, which handle reading
from a config file and matching requests to the whitelist. */
import (
"errors"
"os"
)
/* Stores a map between a string (bearer token) and a list of unmarshaled JSONS */
var authConfig any;
var authConfigSetup bool = false;
/* Opens and reads a file at the path */
func SetupAuthConfig(filePath string) (err error) {
if authConfigSetup {return errors.New("Auth configuration already set up!")}
// Open and read file contents
fileContents, err := os.ReadFile(filePath);
if err != nil {return}
// Unmarshal
authConfig = unmarshalJSON(fileContents);
if authConfig == nil {return errors.New("Invalid JSON config!");}
print(match(authConfig, authConfig), "\n")
// Finish setup
authConfigSetup = true;
return nil;
}
/* Gets a reference copy to the config data */
func GetAuthConfigData() (any, bool) {
return authConfig, authConfigSetup;
}