Documentation
¶
Index ¶
- func DatabaseMiddleware(server *Server, forceDBE bool, getDBName GetDatabaseNameFn) heligo.Middleware
- func DatabaseMiddlewareStd(server *Server, forceDBE bool) heligo.Middleware
- func DatabaseMiddlewareWithName(server *Server, dbname string) heligo.Middleware
- func GenerateToken(role, secret string) (string, error)
- func HTTPLogger(logger *logging.Logger) heligo.Middleware
- func ReadInputRecords(r heligo.Request) ([]database.Record, error)
- func ReleaseSession(ctx context.Context, status int, server *Server, session *Session)
- func TableCreateHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableDeleteHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableGetHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableListHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableUpdateHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func WriteBadRequest(w http.ResponseWriter, err error) (int, error)
- func WriteEmpty(w http.ResponseWriter, status int) (int, error)
- func WriteError(w http.ResponseWriter, err error) (int, error)
- func WriteJSON[O any](w http.ResponseWriter, status int, obj O) (int, error)
- func WriteJSONString(w http.ResponseWriter, status int, json []byte) (int, error)
- func WriteServerError(w http.ResponseWriter, err error) (int, error)
- type Claims
- type Config
- type ConfigOptions
- type Data
- type GetDatabaseNameFn
- type Server
- type Session
- type SessionList
- type SessionManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatabaseMiddleware ¶
func DatabaseMiddleware(server *Server, forceDBE bool, getDBName GetDatabaseNameFn) heligo.Middleware
func DatabaseMiddlewareStd ¶ added in v0.1.2
func DatabaseMiddlewareStd(server *Server, forceDBE bool) heligo.Middleware
func DatabaseMiddlewareWithName ¶ added in v0.1.2
func DatabaseMiddlewareWithName(server *Server, dbname string) heligo.Middleware
func GenerateToken ¶
func HTTPLogger ¶
func HTTPLogger(logger *logging.Logger) heligo.Middleware
func ReleaseSession ¶
func TableCreateHandler ¶
func TableDeleteHandler ¶ added in v0.1.2
func TableGetHandler ¶ added in v0.1.2
func TableListHandler ¶
func TableUpdateHandler ¶ added in v0.1.2
func WriteBadRequest ¶
func WriteBadRequest(w http.ResponseWriter, err error) (int, error)
func WriteEmpty ¶
func WriteEmpty(w http.ResponseWriter, status int) (int, error)
func WriteError ¶
func WriteError(w http.ResponseWriter, err error) (int, error)
func WriteJSONString ¶
func WriteServerError ¶
func WriteServerError(w http.ResponseWriter, err error) (int, error)
Types ¶
type Claims ¶
type Claims struct {
Role string `json:"role"`
Id string `json:"id"`
jwt.RegisteredClaims
}
type Config ¶
type Config struct {
Address string `comment:"Server address and port (default: localhost:4000)"`
AllowAnon bool `comment:"Allow unauthenticated connections (default: false)"`
JWTSecret string `comment:"Secret for JWT tokens"`
SessionMode string `comment:"Session mode: none, role (default: role)"`
EnableAdminRoute bool `comment:"Enable administration of databases and tables (default: false)"`
EnableAPIRoute bool `comment:"Enable API access (default: true)"`
BaseAPIURL string `comment:"Base URL for the API (default: /api)"`
ShortAPIURL bool `comment:"Avoid database name in API URL (needs a single allowed database)"`
BaseAdminURL string `comment:"Base URL for the Admin API (default: /admin)"`
CORSAllowedOrigins []string `comment:"CORS Access-Control-Allow-Origin (default: [*] for all)"`
CORSAllowCredentials bool `comment:"CORS Access-Control-Allow-Credentials (default: false)"`
EnableDebugRoute bool `comment:"Enable debug access (default: false)"`
Database database.Config `comment:"Database configuration"`
Logging logging.Config `comment:"Logging configuration"`
}
Config holds the current configuration
type ConfigOptions ¶
type GetDatabaseNameFn ¶ added in v0.1.2
type Server ¶
type Server struct {
Config *Config
Logger *logging.Logger
DBE *database.DbEngine
HTTP *http.Server
OnBeforeStart func(*Server)
OnBeforeShutdown func(*Server)
// contains filtered or unexported fields
}
func NewServerWithConfig ¶
func NewServerWithConfig(config map[string]any, configOpts *ConfigOptions) (*Server, error)
type Session ¶
type SessionList ¶
type SessionList struct {
// contains filtered or unexported fields
}
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.