Add a media endpoint route
This commit is contained in:
parent
206a64ed4b
commit
21cd718604
2 changed files with 39 additions and 0 deletions
|
@ -225,4 +225,42 @@ class MicropubController extends Controller
|
|||
'error_description' => 'No token provided with request',
|
||||
], 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a media item posted to the media endpoint.
|
||||
*
|
||||
* @param Illuminate\Http\Request $request
|
||||
* @return Illuminate\Http\Response
|
||||
*/
|
||||
public function media(Request $request)
|
||||
{
|
||||
//can this go in middleware
|
||||
$httpAuth = $request->header('Authorization');
|
||||
if (preg_match('/Bearer (.+)/', $httpAuth, $match)) {
|
||||
$token = $match[1];
|
||||
$valid = $this->tokenService->validateToken($token);
|
||||
|
||||
if ($valid === null) {
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'invalid_token',
|
||||
'error_description' => 'The provided token did not pass validation',
|
||||
], 400);
|
||||
}
|
||||
|
||||
//check post scope
|
||||
|
||||
//check media valid
|
||||
|
||||
//save media
|
||||
|
||||
//return URL for media
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'no_token',
|
||||
'error_description' => 'There was no token provided with the request'
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ Route::group(['domain' => config('url.longurl')], function () {
|
|||
// Micropub Endpoint
|
||||
Route::get('api/post', 'MicropubController@get');
|
||||
Route::post('api/post', 'MicropubController@post');
|
||||
Route::post('api/media', 'MicropubController@media');
|
||||
|
||||
//webmention
|
||||
Route::get('webmention', 'WebMentionsController@get');
|
||||
|
|
Loading…
Add table
Reference in a new issue