Skip to content

Commit

Permalink
added auth headers NOT TESTED
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Jan 25, 2017
1 parent 938ad95 commit a54f1f6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/rest/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@

class QueryBuilder extends \hiqdev\hiart\AbstractQueryBuilder
{
protected $authHeaders = [];

/**
* This function is for you to provide your authentication.
* @param Query $query
*/
public function buildAuth(Query $query)
{
$auth = $this->db->getAuth();
if (isset($auth['headerToken'])) {
$authHeaders['Authorization'] = 'token ' . $auth['headerToken'];
}
if (isset($auth['headerBearer'])) {
$authHeaders['Authorization'] = 'Bearer ' . $auth['headerBearer'];
}
}

public function buildMethod(Query $query)
Expand All @@ -45,7 +54,7 @@ public function buildUri(Query $query)

public function buildHeaders(Query $query)
{
return [];
return $this->authHeaders;
}

public function buildProtocolVersion(Query $query)
Expand Down

0 comments on commit a54f1f6

Please sign in to comment.