Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
media-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaflix
media-backend
Commits
2e280d8b
Verified
Commit
2e280d8b
authored
4 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Adapted routes to new paths
parent
c9d4bf9b
Branches
Branches containing commit
Tags
v0.0.5
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/dto.rs
+27
-27
27 additions, 27 deletions
src/dto.rs
src/dto_helpers.rs
+11
-11
11 additions, 11 deletions
src/dto_helpers.rs
src/main.rs
+21
-21
21 additions, 21 deletions
src/main.rs
with
59 additions
and
59 deletions
src/dto.rs
+
27
−
27
View file @
2e280d8b
...
@@ -6,15 +6,15 @@ use crate::models::*;
...
@@ -6,15 +6,15 @@ use crate::models::*;
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
Title
Dto
{
pub
struct
Content
Dto
{
pub
ids
:
Title
IdDto
,
pub
ids
:
Content
IdDto
,
pub
kind
:
String
,
pub
kind
:
String
,
pub
original_language
:
Option
<
String
>
,
pub
original_language
:
Option
<
String
>
,
pub
runtime
:
Option
<
i32
>
,
pub
runtime
:
Option
<
i32
>
,
pub
year_start
:
Option
<
i32
>
,
pub
year_start
:
Option
<
i32
>
,
pub
year_end
:
Option
<
i32
>
,
pub
year_end
:
Option
<
i32
>
,
pub
titles
:
Vec
<
Title
NameDto
>
,
pub
titles
:
Vec
<
Content
NameDto
>
,
pub
descriptions
:
Vec
<
Title
DescriptionDto
>
,
pub
descriptions
:
Vec
<
Content
DescriptionDto
>
,
pub
cast
:
Vec
<
CastDto
>
,
pub
cast
:
Vec
<
CastDto
>
,
pub
genres
:
Vec
<
GenreDto
>
,
pub
genres
:
Vec
<
GenreDto
>
,
pub
ratings
:
Vec
<
RatingDto
>
,
pub
ratings
:
Vec
<
RatingDto
>
,
...
@@ -26,11 +26,11 @@ pub struct TitleDto {
...
@@ -26,11 +26,11 @@ pub struct TitleDto {
pub
updated_at
:
chrono
::
DateTime
<
chrono
::
Utc
>
,
pub
updated_at
:
chrono
::
DateTime
<
chrono
::
Utc
>
,
}
}
impl
Title
Dto
{
impl
Content
Dto
{
pub
fn
of
(
pub
fn
of
(
src
:
Title
,
src
:
Title
,
titles
:
Vec
<
Title
NameDto
>
,
titles
:
Vec
<
Content
NameDto
>
,
descriptions
:
Vec
<
Title
DescriptionDto
>
,
descriptions
:
Vec
<
Content
DescriptionDto
>
,
cast
:
Vec
<
CastDto
>
,
cast
:
Vec
<
CastDto
>
,
genres
:
Vec
<
GenreDto
>
,
genres
:
Vec
<
GenreDto
>
,
ratings
:
Vec
<
RatingDto
>
,
ratings
:
Vec
<
RatingDto
>
,
...
@@ -39,8 +39,8 @@ impl TitleDto {
...
@@ -39,8 +39,8 @@ impl TitleDto {
subtitles
:
Vec
<
SubtitleDto
>
,
subtitles
:
Vec
<
SubtitleDto
>
,
preview
:
Option
<
String
>
,
preview
:
Option
<
String
>
,
)
->
Self
{
)
->
Self
{
Title
Dto
{
Content
Dto
{
ids
:
Title
IdDto
{
ids
:
Content
IdDto
{
uuid
:
src
.id
,
uuid
:
src
.id
,
imdb
:
src
.imdb_id
,
imdb
:
src
.imdb_id
,
tmdb
:
src
.tmdb_id
,
tmdb
:
src
.tmdb_id
,
...
@@ -68,7 +68,7 @@ impl TitleDto {
...
@@ -68,7 +68,7 @@ impl TitleDto {
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
Title
IdDto
{
pub
struct
Content
IdDto
{
pub
uuid
:
uuid
::
Uuid
,
pub
uuid
:
uuid
::
Uuid
,
pub
imdb
:
Option
<
String
>
,
pub
imdb
:
Option
<
String
>
,
pub
tmdb
:
Option
<
i32
>
,
pub
tmdb
:
Option
<
i32
>
,
...
@@ -77,16 +77,16 @@ pub struct TitleIdDto {
...
@@ -77,16 +77,16 @@ pub struct TitleIdDto {
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
Title
NameDto
{
pub
struct
Content
NameDto
{
pub
region
:
Option
<
String
>
,
pub
region
:
Option
<
String
>
,
pub
languages
:
Vec
<
String
>
,
pub
languages
:
Vec
<
String
>
,
pub
kind
:
String
,
pub
kind
:
String
,
pub
name
:
String
,
pub
name
:
String
,
}
}
impl
From
<
TitleName
>
for
Title
NameDto
{
impl
From
<
TitleName
>
for
Content
NameDto
{
fn
from
(
src
:
TitleName
)
->
Self
{
fn
from
(
src
:
TitleName
)
->
Self
{
Title
NameDto
{
Content
NameDto
{
region
:
src
.region
,
region
:
src
.region
,
languages
:
src
.languages
,
languages
:
src
.languages
,
kind
:
src
.kind
,
kind
:
src
.kind
,
...
@@ -97,7 +97,7 @@ impl From<TitleName> for TitleNameDto {
...
@@ -97,7 +97,7 @@ impl From<TitleName> for TitleNameDto {
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
Title
DescriptionDto
{
pub
struct
Content
DescriptionDto
{
pub
region
:
Option
<
String
>
,
pub
region
:
Option
<
String
>
,
pub
languages
:
Vec
<
String
>
,
pub
languages
:
Vec
<
String
>
,
pub
kind
:
String
,
pub
kind
:
String
,
...
@@ -105,9 +105,9 @@ pub struct TitleDescriptionDto {
...
@@ -105,9 +105,9 @@ pub struct TitleDescriptionDto {
pub
tagline
:
Option
<
String
>
,
pub
tagline
:
Option
<
String
>
,
}
}
impl
From
<
TitleDescription
>
for
Title
DescriptionDto
{
impl
From
<
TitleDescription
>
for
Content
DescriptionDto
{
fn
from
(
src
:
TitleDescription
)
->
Self
{
fn
from
(
src
:
TitleDescription
)
->
Self
{
Title
DescriptionDto
{
Content
DescriptionDto
{
region
:
src
.region
,
region
:
src
.region
,
languages
:
src
.languages
,
languages
:
src
.languages
,
kind
:
src
.kind
,
kind
:
src
.kind
,
...
@@ -175,20 +175,20 @@ impl From<Person> for PersonDto {
...
@@ -175,20 +175,20 @@ impl From<Person> for PersonDto {
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
Episode
Dto
{
pub
struct
Instalment
Dto
{
pub
season
:
Option
<
String
>
,
pub
season
:
Option
<
String
>
,
pub
episode
:
Option
<
String
>
,
pub
episode
:
Option
<
String
>
,
pub
air_date
:
Option
<
chrono
::
NaiveDate
>
,
pub
air_date
:
Option
<
chrono
::
NaiveDate
>
,
pub
title
:
Title
Dto
,
pub
content
:
Content
Dto
,
}
}
impl
Episode
Dto
{
impl
Instalment
Dto
{
pub
fn
of
(
episode
:
TitleEpisode
,
title
:
Title
Dto
)
->
Self
{
pub
fn
of
(
episode
:
TitleEpisode
,
content
:
Content
Dto
)
->
Self
{
Episode
Dto
{
Instalment
Dto
{
season
:
episode
.season_number
,
season
:
episode
.season_number
,
episode
:
episode
.episode_number
,
episode
:
episode
.episode_number
,
air_date
:
episode
.air_date
,
air_date
:
episode
.air_date
,
title
,
content
,
}
}
}
}
}
}
...
@@ -271,14 +271,14 @@ impl SubtitleDto {
...
@@ -271,14 +271,14 @@ impl SubtitleDto {
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
GenreWith
Titles
Dto
{
pub
struct
GenreWith
Content
Dto
{
pub
genre
:
GenreDto
,
pub
genre
:
GenreDto
,
pub
titles
:
Vec
<
Title
Dto
>
,
pub
content
:
Vec
<
Content
Dto
>
,
}
}
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
Title
MetaDto
{
pub
struct
Content
MetaDto
{
pub
title
:
Title
Dto
,
pub
content
:
Content
Dto
,
pub
show
:
Option
<
Episode
Dto
>
,
pub
instalment
:
Option
<
Instalment
Dto
>
,
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/dto_helpers.rs
+
11
−
11
View file @
2e280d8b
...
@@ -7,7 +7,7 @@ use crate::dto::*;
...
@@ -7,7 +7,7 @@ use crate::dto::*;
use
crate
::
models
::
*
;
use
crate
::
models
::
*
;
use
crate
::
schema
::
*
;
use
crate
::
schema
::
*
;
pub
fn
load_episodes
(
db
:
&
PgConnection
,
config
:
&
Config
,
title_id
:
Uuid
)
->
QueryResult
<
Vec
<
Episode
Dto
>>
{
pub
fn
load_episodes
(
db
:
&
PgConnection
,
config
:
&
Config
,
title_id
:
Uuid
)
->
QueryResult
<
Vec
<
Instalment
Dto
>>
{
let
titles
:
Vec
<
(
TitleEpisode
,
Title
)
>
=
title_episodes
::
table
let
titles
:
Vec
<
(
TitleEpisode
,
Title
)
>
=
title_episodes
::
table
.filter
(
title_episodes
::
show_id
.eq
(
title_id
))
.filter
(
title_episodes
::
show_id
.eq
(
title_id
))
.inner_join
(
titles
::
table
.on
(
titles
::
id
.eq
(
title_episodes
::
episode_id
)))
.inner_join
(
titles
::
table
.on
(
titles
::
id
.eq
(
title_episodes
::
episode_id
)))
...
@@ -16,19 +16,19 @@ pub fn load_episodes(db: &PgConnection, config: &Config, title_id: Uuid) -> Quer
...
@@ -16,19 +16,19 @@ pub fn load_episodes(db: &PgConnection, config: &Config, title_id: Uuid) -> Quer
let
(
episodes
,
titles
):
(
Vec
<
TitleEpisode
>
,
Vec
<
Title
>
)
=
titles
.into_iter
()
.unzip
();
let
(
episodes
,
titles
):
(
Vec
<
TitleEpisode
>
,
Vec
<
Title
>
)
=
titles
.into_iter
()
.unzip
();
let
titles
=
load_titles
(
db
,
config
,
titles
)
?
;
let
titles
=
load_titles
(
db
,
config
,
titles
)
?
;
Ok
(
episodes
.into_iter
()
.zip
(
titles
)
Ok
(
episodes
.into_iter
()
.zip
(
titles
)
.map
(|(
episode
,
title
)|
Episode
Dto
::
of
(
episode
,
title
))
.map
(|(
episode
,
title
)|
Instalment
Dto
::
of
(
episode
,
title
))
.collect
::
<
Vec
<
_
>>
())
.collect
::
<
Vec
<
_
>>
())
}
}
pub
fn
load_show
(
db
:
&
PgConnection
,
config
:
&
Config
,
title_id
:
Uuid
)
->
QueryResult
<
Episode
Dto
>
{
pub
fn
load_show
(
db
:
&
PgConnection
,
config
:
&
Config
,
title_id
:
Uuid
)
->
QueryResult
<
Instalment
Dto
>
{
let
(
episode
,
show
)
=
title_episodes
::
table
let
(
episode
,
show
)
=
title_episodes
::
table
.filter
(
title_episodes
::
episode_id
.eq
(
title_id
))
.filter
(
title_episodes
::
episode_id
.eq
(
title_id
))
.inner_join
(
titles
::
table
.on
(
titles
::
id
.eq
(
title_episodes
::
show_id
)))
.inner_join
(
titles
::
table
.on
(
titles
::
id
.eq
(
title_episodes
::
show_id
)))
.first
::
<
(
TitleEpisode
,
Title
)
>
(
db
)
?
;
.first
::
<
(
TitleEpisode
,
Title
)
>
(
db
)
?
;
Ok
(
Episode
Dto
::
of
(
episode
,
load_title
(
db
,
config
,
show
)
?
))
Ok
(
Instalment
Dto
::
of
(
episode
,
load_title
(
db
,
config
,
show
)
?
))
}
}
pub
fn
load_title
(
db
:
&
PgConnection
,
config
:
&
Config
,
title
:
Title
)
->
QueryResult
<
Title
Dto
>
{
pub
fn
load_title
(
db
:
&
PgConnection
,
config
:
&
Config
,
title
:
Title
)
->
QueryResult
<
Content
Dto
>
{
let
title_names
:
Vec
<
TitleName
>
=
TitleName
::
belonging_to
(
&
title
)
let
title_names
:
Vec
<
TitleName
>
=
TitleName
::
belonging_to
(
&
title
)
.load
::
<
TitleName
>
(
db
)
?
;
.load
::
<
TitleName
>
(
db
)
?
;
let
title_descriptions
:
Vec
<
TitleDescription
>
=
TitleDescription
::
belonging_to
(
&
title
)
let
title_descriptions
:
Vec
<
TitleDescription
>
=
TitleDescription
::
belonging_to
(
&
title
)
...
@@ -59,7 +59,7 @@ pub fn load_title(db: &PgConnection, config: &Config, title: Title) -> QueryResu
...
@@ -59,7 +59,7 @@ pub fn load_title(db: &PgConnection, config: &Config, title: Title) -> QueryResu
))
))
}
}
pub
fn
load_titles
(
db
:
&
PgConnection
,
config
:
&
Config
,
titles
:
Vec
<
Title
>
)
->
QueryResult
<
Vec
<
Title
Dto
>>
{
pub
fn
load_titles
(
db
:
&
PgConnection
,
config
:
&
Config
,
titles
:
Vec
<
Title
>
)
->
QueryResult
<
Vec
<
Content
Dto
>>
{
let
title_names
:
Vec
<
Vec
<
TitleName
>>
=
TitleName
::
belonging_to
(
&
titles
)
let
title_names
:
Vec
<
Vec
<
TitleName
>>
=
TitleName
::
belonging_to
(
&
titles
)
.load
::
<
TitleName
>
(
db
)
?
.load
::
<
TitleName
>
(
db
)
?
.grouped_by
(
&
titles
);
.grouped_by
(
&
titles
);
...
@@ -113,7 +113,7 @@ pub fn load_titles(db: &PgConnection, config: &Config, titles: Vec<Title>) -> Qu
...
@@ -113,7 +113,7 @@ pub fn load_titles(db: &PgConnection, config: &Config, titles: Vec<Title>) -> Qu
images
,
media
,
subtitles
,
images
,
media
,
subtitles
,
preview
,
preview
,
)
)
})
.collect
::
<
Vec
<
Title
Dto
>>
())
})
.collect
::
<
Vec
<
Content
Dto
>>
())
}
}
fn
process_title
(
fn
process_title
(
...
@@ -122,14 +122,14 @@ fn process_title(
...
@@ -122,14 +122,14 @@ fn process_title(
cast
:
Vec
<
(
TitleCast
,
Person
)
>
,
genres
:
Vec
<
(
TitleGenre
,
Genre
)
>
,
ratings
:
Vec
<
TitleRating
>
,
cast
:
Vec
<
(
TitleCast
,
Person
)
>
,
genres
:
Vec
<
(
TitleGenre
,
Genre
)
>
,
ratings
:
Vec
<
TitleRating
>
,
images
:
Vec
<
TitleImage
>
,
media
:
Vec
<
TitleMedium
>
,
subtitles
:
Vec
<
TitleSubtitle
>
,
images
:
Vec
<
TitleImage
>
,
media
:
Vec
<
TitleMedium
>
,
subtitles
:
Vec
<
TitleSubtitle
>
,
preview
:
Option
<
TitlePreview
>
,
preview
:
Option
<
TitlePreview
>
,
)
->
Title
Dto
{
)
->
Content
Dto
{
Title
Dto
::
of
(
Content
Dto
::
of
(
title
,
title
,
names
.into_iter
()
.map
(|
src
|
{
names
.into_iter
()
.map
(|
src
|
{
Title
NameDto
::
from
(
src
)
Content
NameDto
::
from
(
src
)
})
.collect
::
<
Vec
<
_
>>
(),
})
.collect
::
<
Vec
<
_
>>
(),
descriptions
.into_iter
()
.map
(|
src
|
{
descriptions
.into_iter
()
.map
(|
src
|
{
Title
DescriptionDto
::
from
(
src
)
Content
DescriptionDto
::
from
(
src
)
})
.collect
::
<
Vec
<
_
>>
(),
})
.collect
::
<
Vec
<
_
>>
(),
cast
.into_iter
()
.map
(|
src
|
{
cast
.into_iter
()
.map
(|
src
|
{
let
(
cast
,
person
)
=
src
;
let
(
cast
,
person
)
=
src
;
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
21
−
21
View file @
2e280d8b
...
@@ -34,7 +34,7 @@ fn list_genres(db: MediaflixConnection) -> QueryResult<Json<Vec<GenreDto>>> {
...
@@ -34,7 +34,7 @@ fn list_genres(db: MediaflixConnection) -> QueryResult<Json<Vec<GenreDto>>> {
}
}
#[get(
"/api/v1/genres/<genre_id>"
)]
#[get(
"/api/v1/genres/<genre_id>"
)]
fn
get_genre
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
,
genre_id
:
ParamUuid
)
->
QueryResult
<
Json
<
GenreWith
Titles
Dto
>>
{
fn
get_genre
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
,
genre_id
:
ParamUuid
)
->
QueryResult
<
Json
<
GenreWith
Content
Dto
>>
{
use
media_backend
::
schema
::
*
;
use
media_backend
::
schema
::
*
;
let
genre
:
Genre
=
genres
::
table
let
genre
:
Genre
=
genres
::
table
.find
(
genre_id
.uuid
())
.find
(
genre_id
.uuid
())
...
@@ -44,47 +44,47 @@ fn get_genre(db: MediaflixConnection, config: State<Config>, genre_id: ParamUuid
...
@@ -44,47 +44,47 @@ fn get_genre(db: MediaflixConnection, config: State<Config>, genre_id: ParamUuid
.inner_join
(
titles
::
table
)
.inner_join
(
titles
::
table
)
.select
(
titles
::
all_columns
)
.select
(
titles
::
all_columns
)
.load
::
<
Title
>
(
&
db
.0
)
?
;
.load
::
<
Title
>
(
&
db
.0
)
?
;
Ok
(
Json
(
GenreWith
Titles
Dto
{
Ok
(
Json
(
GenreWith
Content
Dto
{
genre
:
GenreDto
::
from
(
genre
),
genre
:
GenreDto
::
from
(
genre
),
titles
:
load_titles
(
&
db
.0
,
&
config
,
titles
)
?
,
content
:
load_titles
(
&
db
.0
,
&
config
,
titles
)
?
,
}))
}))
}
}
#[get(
"/api/v1/
titles
"
)]
#[get(
"/api/v1/
content
"
)]
fn
list_
titles
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
)
->
QueryResult
<
Json
<
Vec
<
Title
Dto
>>>
{
fn
list_
content
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
)
->
QueryResult
<
Json
<
Vec
<
Content
Dto
>>>
{
use
media_backend
::
schema
::
*
;
use
media_backend
::
schema
::
*
;
let
titles
=
titles
::
table
let
content
=
titles
::
table
.left_outer_join
(
title_episodes
::
table
.on
(
title_episodes
::
episode_id
.eq
(
titles
::
id
)))
.left_outer_join
(
title_episodes
::
table
.on
(
title_episodes
::
episode_id
.eq
(
titles
::
id
)))
.filter
(
title_episodes
::
id
.is_null
())
.filter
(
title_episodes
::
id
.is_null
())
.select
(
titles
::
all_columns
)
.select
(
titles
::
all_columns
)
.load
::
<
Title
>
(
&
db
.0
)
?
;
.load
::
<
Title
>
(
&
db
.0
)
?
;
Ok
(
Json
(
load_titles
(
&
db
.0
,
&
config
,
titles
)
?
))
Ok
(
Json
(
load_titles
(
&
db
.0
,
&
config
,
content
)
?
))
}
}
#[get(
"/api/v1/
titles/<title
_id>"
)]
#[get(
"/api/v1/
content/<content
_id>"
)]
fn
get_
title
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
,
title
_id
:
ParamUuid
)
->
QueryResult
<
Json
<
Title
MetaDto
>>
{
fn
get_
content
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
,
content
_id
:
ParamUuid
)
->
QueryResult
<
Json
<
Content
MetaDto
>>
{
use
media_backend
::
schema
::
*
;
use
media_backend
::
schema
::
*
;
let
title
=
load_title
(
let
content
=
load_title
(
&
db
.0
,
&
db
.0
,
&
config
,
&
config
,
titles
::
table
titles
::
table
.find
(
title
_id
.uuid
())
.find
(
content
_id
.uuid
())
.first
::
<
Title
>
(
&
db
.0
)
?
,
.first
::
<
Title
>
(
&
db
.0
)
?
,
)
?
;
)
?
;
match
title
.kind
.as_str
()
{
match
content
.kind
.as_str
()
{
"episode"
=>
{
"episode"
=>
{
let
show
=
load_show
(
&
db
.0
,
&
config
,
title
.ids.uuid
)
?
;
let
show
=
load_show
(
&
db
.0
,
&
config
,
content
.ids.uuid
)
?
;
Ok
(
Json
(
Title
MetaDto
{
title
,
show
:
Some
(
show
)
}))
Ok
(
Json
(
Content
MetaDto
{
content
,
instalment
:
Some
(
show
)
}))
}
}
_
=>
{
_
=>
{
Ok
(
Json
(
Title
MetaDto
{
title
,
show
:
None
}))
Ok
(
Json
(
Content
MetaDto
{
content
,
instalment
:
None
}))
}
}
}
}
}
}
#[get(
"/api/v1/
titles/<title
_id>/episodes"
)]
#[get(
"/api/v1/
content/<content
_id>/episodes"
)]
fn
list_episodes
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
,
title
_id
:
ParamUuid
)
->
QueryResult
<
Json
<
Vec
<
Episode
Dto
>>>
{
fn
list_episodes
(
db
:
MediaflixConnection
,
config
:
State
<
Config
>
,
content
_id
:
ParamUuid
)
->
QueryResult
<
Json
<
Vec
<
Instalment
Dto
>>>
{
Ok
(
Json
(
load_episodes
(
&
db
.0
,
&
config
,
title
_id
.uuid
())
?
))
Ok
(
Json
(
load_episodes
(
&
db
.0
,
&
config
,
content
_id
.uuid
())
?
))
}
}
fn
main
()
->
Result
<
(),
Box
<
dyn
std
::
error
::
Error
>>
{
fn
main
()
->
Result
<
(),
Box
<
dyn
std
::
error
::
Error
>>
{
...
@@ -100,12 +100,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
...
@@ -100,12 +100,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rocket
::
routes!
[
rocket
::
routes!
[
list_genres
,
list_genres
,
get_genre
,
get_genre
,
list_
titles
,
list_
content
,
get_
title
,
get_
content
,
list_episodes
list_episodes
],
],
)
)
.mount
(
"/
static
"
,
StaticFiles
::
from
(
env
::
var
(
"MEDIAFLIX_PATH"
)
?
))
.mount
(
"/
media
"
,
StaticFiles
::
from
(
env
::
var
(
"MEDIAFLIX_PATH"
)
?
))
.attach
(
MediaflixConnection
::
fairing
())
.attach
(
MediaflixConnection
::
fairing
())
.attach
(
rocket_cors
::
CorsOptions
{
.attach
(
rocket_cors
::
CorsOptions
{
allowed_headers
:
AllowedHeaders
::
some
(
&
[
"Authorization"
,
"Accept"
,
"Accept-Language"
]),
allowed_headers
:
AllowedHeaders
::
some
(
&
[
"Authorization"
,
"Accept"
,
"Accept-Language"
]),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment