Thruk::Context - Main Context Object
use Thruk::Context;
Thruk::Context
Main Context Object
new()
return new context object
return request object
return response object
return cluster object
return db manager
return metrics object
detach to other controller
detach_error($c, $data)
end current request with an error.
$data contains: { msg short error message descr long description of the error code http return code, defaults to 500; log flag wether error should be logged. Error codes > 500 are automatically logged if `log` is undefined debug_information more details which will be logged, (string / array) skip_escape skip escaping html }
return list of template include paths
detach to other controller
detach to excel controller
detach to gd controller
$c->authenticate(%options)
authenticate current request user
options are: { username => force this username skip_db_access => do not access the livestatus to fetch roles apikey => use api key to authenticate superuser => flag wether this user should be a superuser internal => flag wether this user is an internal technical user roles => limit roles to this set keep_session => do not update current session cookie }
get username from env
returns $username, $auth_src, $roles, $superuser, $internal, $sessionid, $sessiondata, $force_roles
return if a user exists
return/set errors
clear all errors
$c->check_user_roles(<role>)
$c->check_permissions(<type>, ...)
$c->check_cmd_permissions(<type>, ...)
$c->cache()
$c->cookie($name, [$value], [$options])
returns cookie from current request.
sets a cookie for current response if value is defined.
options are available as descrbed here: "cookies" in Plack::Response
basically: domain, expires, path, httponly, secure, max-age
$c->cookies($name)
returns cookie from current request.
$c->redirect_to(<url>)
$c->redirect_to_detached(<url>)
$c->url_with(<data>)
translate_request_path(<path_info>, $config, $env)
translate paths, /naemon/cgi-bin to /thruk/cgi-bin/ or /<omd-site/thruk/cgi-bin/... to /thruk/cgi-bin/... so later functions can use /thruk/... for everything, regardless of the deployment path.
$c->has_route(<url>)
$c->sub_request(<url>, [<method>], [<postdata>], [<rendered>])
$c->want_json_response()
returns true if request indicates a json response.
$c->clone_user_config()
replace $c->config with a deepcopy of it
$c->reread_config()
replace $c->config with a newly parsed config
$c->log->...
compat wrapper for accessing logger
$c->get_cookie_domain
return domain used for cookies
register_cron_entries($c, $res)
finalize request data by adding profile and headers
$c->set_stats_common_totals
adds common statistics
$c->add_profile({ name => ..., [ text => \@txtprofiles ], [ html => \@htmlprofiles ] })
add profile to stash