Add API root information
This commit is contained in:
parent
1e1f138902
commit
777e786873
@ -10,4 +10,14 @@ class HomeController extends Controller
|
||||
->with('transparent_navbar', option('transparent_navbar', false))
|
||||
->with('home_pic_url', option('home_pic_url') ?: config('options.home_pic_url'));
|
||||
}
|
||||
|
||||
public function apiRoot()
|
||||
{
|
||||
return response()->json([
|
||||
'blessing_skin' => config('app.version'),
|
||||
'spec' => 0,
|
||||
'copyright' => bs_copyright(),
|
||||
'site_name' => option('site_name'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,22 @@ if (! function_exists('bs_menu')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('bs_copyright')) {
|
||||
function bs_copyright()
|
||||
{
|
||||
return Arr::get(
|
||||
[
|
||||
'Powered with ❤ by Blessing Skin Server.',
|
||||
'Powered by Blessing Skin Server.',
|
||||
'Proudly powered by Blessing Skin Server.',
|
||||
'由 Blessing Skin Server 强力驱动。',
|
||||
'自豪地采用 Blessing Skin Server。'
|
||||
],
|
||||
option_localized('copyright_prefer', 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('option')) {
|
||||
/**
|
||||
* Get / set the specified option value.
|
||||
|
@ -1,12 +1,7 @@
|
||||
{!!
|
||||
Arr::get(
|
||||
[
|
||||
'Powered with ❤ by <a href="https://github.com/bs-community/blessing-skin-server">Blessing Skin Server</a>.',
|
||||
'Powered by <a href="https://github.com/bs-community/blessing-skin-server">Blessing Skin Server</a>.',
|
||||
'Proudly powered by <a href="https://github.com/bs-community/blessing-skin-server">Blessing Skin Server</a>.',
|
||||
'由 <a href="https://github.com/bs-community/blessing-skin-server">Blessing Skin Server</a> 强力驱动。',
|
||||
'自豪地采用 <a href="https://github.com/bs-community/blessing-skin-server">Blessing Skin Server</a>。'
|
||||
],
|
||||
option_localized('copyright_prefer', 0)
|
||||
)
|
||||
str_replace(
|
||||
'Blessing Skin Server',
|
||||
'<a href="https://github.com/bs-community/blessing-skin-server">Blessing Skin Server</a>',
|
||||
bs_copyright()
|
||||
)
|
||||
!!}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
Route::any('/', 'HomeController@apiRoot');
|
||||
|
||||
Route::prefix('auth')->group(function () {
|
||||
Route::post('login', 'AuthController@jwtLogin');
|
||||
Route::post('logout', 'AuthController@jwtLogout')->middleware('auth:jwt');
|
||||
|
@ -4,6 +4,9 @@ mod auth;
|
||||
#[cfg(test)]
|
||||
mod closet;
|
||||
|
||||
#[cfg(test)]
|
||||
mod misc;
|
||||
|
||||
#[cfg(test)]
|
||||
mod players;
|
||||
|
||||
|
21
tests/Api/tests/misc.rs
Normal file
21
tests/Api/tests/misc.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct RootInfo {
|
||||
blessing_skin: String,
|
||||
spec: u8,
|
||||
copyright: String,
|
||||
site_name: String,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn api_root() {
|
||||
let body = reqwest::get("http://127.0.0.1:32123/api")
|
||||
.unwrap()
|
||||
.json::<RootInfo>()
|
||||
.unwrap();
|
||||
assert!(body.blessing_skin.starts_with("4"));
|
||||
assert_eq!(body.spec, 0);
|
||||
assert_eq!(body.copyright, "Powered with ❤ by Blessing Skin Server.");
|
||||
assert_eq!(body.site_name, "Blessing Skin");
|
||||
}
|
@ -42,4 +42,9 @@ class HomeControllerTest extends TestCase
|
||||
});
|
||||
$this->get('/');
|
||||
}
|
||||
|
||||
public function testApiRoot()
|
||||
{
|
||||
$this->get('/api')->assertJson(['spec' => 0]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user