class Http

Methods

static 
redirect(string $url = '/')

Redirect to a given URL.

static int
status(int $statusCode = NULL)

If given a valid status code, sets the status and return the previous status code.

void
header($headerName, $value, bool $replacePrevious = TRUE)

Sets the header response header.

__construct(string $timezone = 'America/Phoenix')

Http constructor.

get(callable $cb)

Defines a GET callback

post(callable $cb)

Defines a POST callback

put(callable $cb)

Defines a PUT callback

patch(callable $cb)

Defines a PATCH callback

delete(callable $cb)

Defines a DELETE callback

error(callable $cb)

Defines the global exception handler

$this
before(Closure $f)

Set a callback to be run before any route callback is executed.

$this
after(Closure $f)

Set a callback to be run after any route callback is executed.

void
exec()

Runs the route

void
send(int $statusCode = 200, string $contentType = 'application/json', string $content = '')

Sends a response and exits script execution.

void
handleError(Exception $e)

This is really an exception handler "error" is just syntactical sugar

void
abort(int $statusCode = 404, string $message = 'Sorry, something went wrong.')

A convenience method to abort the route and send a response with the given status & message

string
__toString()

No description

Details

at line line 25
static redirect(string $url = '/')

Redirect to a given URL.

Exits execution.

Parameters

string $url

at line line 42
static int status(int $statusCode = NULL)

If given a valid status code, sets the status and return the previous status code.

If not, returns the current status code.

Parameters

int $statusCode

Return Value

int

Exceptions

InvalidStatusCode

at line line 69
void header($headerName, $value, bool $replacePrevious = TRUE)

Sets the header response header.

  • Convenience method proxy for the Response class

Parameters

$headerName
$value
bool $replacePrevious

Return Value

void

at line line 79
__construct(string $timezone = 'America/Phoenix')

Http constructor.

Parameters

string $timezone

at line line 121
Http get(callable $cb)

Defines a GET callback

Parameters

callable $cb

Return Value

Http $this

at line line 137
Http post(callable $cb)

Defines a POST callback

Parameters

callable $cb

Return Value

Http $this

at line line 153
Http put(callable $cb)

Defines a PUT callback

Parameters

callable $cb

Return Value

Http $this

at line line 169
Http patch(callable $cb)

Defines a PATCH callback

Parameters

callable $cb

Return Value

Http $this

at line line 185
Http delete(callable $cb)

Defines a DELETE callback

Parameters

callable $cb

Return Value

Http $this

at line line 201
Http error(callable $cb)

Defines the global exception handler

Parameters

callable $cb

Return Value

Http $this

at line line 217
$this before(Closure $f)

Set a callback to be run before any route callback is executed.

Called with the Http instance as it's one argument.

Parameters

Closure $f

Return Value

$this

at line line 245
$this after(Closure $f)

Set a callback to be run after any route callback is executed.

Called with the Http instance as it's one argument.

Parameters

Closure $f

Return Value

$this

at line line 270
void exec()

Runs the route

Return Value

void

at line line 293
void send(int $statusCode = 200, string $contentType = 'application/json', string $content = '')

Sends a response and exits script execution.

Parameters

int $statusCode
string $contentType
string $content

Return Value

void

Exceptions

InvalidStatusCode

at line line 331
void handleError(Exception $e)

This is really an exception handler "error" is just syntactical sugar

Parameters

Exception $e

Return Value

void

at line line 345
void abort(int $statusCode = 404, string $message = 'Sorry, something went wrong.')

A convenience method to abort the route and send a response with the given status & message

Parameters

int $statusCode
string $message

Return Value

void

at line line 353
string __toString()

Return Value

string