NAME

Thruk::Context - Main Context Object

SYNOPSIS

use Thruk::Context;

DESCRIPTION

Thruk::Context Main Context Object

METHODS

new

new()

return new context object

request

return request object

response

return response object

cluster

return cluster object

db

return db manager

metrics

return metrics object

detach

detach to other controller

detach_error

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 }

get_tt_template_paths

return list of template include paths

render

detach to other controller

render_excel

detach to excel controller

render_gd

detach to gd controller

authenticate

$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 }

_request_username

get username from env

returns $username, $auth_src, $roles, $superuser, $internal, $sessionid, $sessiondata, $force_roles

user_exists

return if a user exists

error

return/set errors

clear_errors

clear all errors

check_user_roles

$c->check_user_roles(<role>)

check_permissions

$c->check_permissions(<type>, ...)

check_cmd_permissions

$c->check_cmd_permissions(<type>, ...)

cache

$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

cookies

$c->cookies($name)

returns cookie from current request.

redirect_to

$c->redirect_to(<url>)

redirect_to_detached

$c->redirect_to_detached(<url>)

url_with

$c->url_with(<data>)

translate_request_path

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.

has_route

$c->has_route(<url>)

sub_request

$c->sub_request(<url>, [<method>], [<postdata>], [<rendered>])

want_json_response

$c->want_json_response()

returns true if request indicates a json response.

clone_user_config

$c->clone_user_config()

replace $c->config with a deepcopy of it

reread_config

$c->reread_config()

replace $c->config with a newly parsed config

log

$c->log->...

compat wrapper for accessing logger

$c->get_cookie_domain

return domain used for cookies

finalize_request

register_cron_entries($c, $res)

finalize request data by adding profile and headers

set_stats_common_totals

$c->set_stats_common_totals

adds common statistics

add_profile

$c->add_profile({ name => ..., [ text => \@txtprofiles ], [ html => \@htmlprofiles ] })

add profile to stash