Skip to content

Latest commit

 

History

History

frontend

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

go-eliona Frontend

The go-eliona Frontend package provides functions and data structures to handle Eliona frontend.

Installation

To use the assets package you must import the package.

import "github.com/eliona-smart-building-assistant/go-eliona/frontend"

Get frontend environment

To retrieve environment information from frontend requests, integrate the NewEnvironmentHandler, which embeds this information into the current context.

err := http.ListenAndServe(":"+common.Getenv("API_SERVER_PORT", "3000"),
    utilshttp.NewCORSEnabledHandler(
        frontend.NewEnvironmentHandler(
            apiserver.NewRouter(
                // add controllers here
            ),
        ),
    ),
)

To use environment information in your controller logic, utilize the GetEnvironment function.

env := frontend.GetEnvironment(ctx)
fmt.Printf("Environment: %v", env)

This function returns a structure like this.

{
"aud": "https://eliona.io/api",
"exp": 1706022910,
"iss": "https://eliona.io",
"role": "api",
"cust_id": "1",
"proj_id": "2",
"role_id": "3",
"user_id": "4",
"entitlements": "user"
}