Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
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
🥺
conduwuit
Commits
ccef1a4c
Commit
ccef1a4c
authored
7 months ago
by
Jason Volk
Browse files
Options
Downloads
Patches
Plain Diff
add formal wrapping for api state
Signed-off-by:
Jason Volk
<
jason@zemos.net
>
parent
5c258f41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!543
Misc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/api/mod.rs
+2
-2
2 additions, 2 deletions
src/api/mod.rs
src/api/router.rs
+2
-4
2 additions, 4 deletions
src/api/router.rs
src/api/router/state.rs
+22
-0
22 additions, 0 deletions
src/api/router/state.rs
src/router/router.rs
+1
-1
1 addition, 1 deletion
src/router/router.rs
with
27 additions
and
7 deletions
src/api/mod.rs
+
2
−
2
View file @
ccef1a4c
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
pub
(
crate
)
use
conduit
::{
debug_info
,
pdu
::
PduEvent
,
utils
,
Error
,
Result
};
pub
(
crate
)
use
conduit
::{
debug_info
,
pdu
::
PduEvent
,
utils
,
Error
,
Result
};
pub
(
crate
)
use
service
::
services
;
pub
(
crate
)
use
service
::
services
;
pub
use
crate
::
router
::
State
;
pub
use
self
::
router
::
State
;
pub
(
crate
)
use
crate
::
router
::{
Ruma
,
RumaResponse
};
pub
(
crate
)
use
self
::
router
::{
Ruma
,
RumaResponse
};
conduit
::
mod_ctor!
{}
conduit
::
mod_ctor!
{}
conduit
::
mod_dtor!
{}
conduit
::
mod_dtor!
{}
This diff is collapsed.
Click to expand it.
src/api/router.rs
+
2
−
4
View file @
ccef1a4c
...
@@ -3,8 +3,7 @@
...
@@ -3,8 +3,7 @@
mod
handler
;
mod
handler
;
mod
request
;
mod
request
;
mod
response
;
mod
response
;
mod
state
;
use
std
::
sync
::
Arc
;
use
axum
::{
use
axum
::{
response
::
IntoResponse
,
response
::
IntoResponse
,
...
@@ -15,11 +14,10 @@
...
@@ -15,11 +14,10 @@
use
http
::
Uri
;
use
http
::
Uri
;
use
self
::
handler
::
RouterExt
;
use
self
::
handler
::
RouterExt
;
pub
use
self
::
state
::
State
;
pub
(
super
)
use
self
::{
args
::
Args
as
Ruma
,
response
::
RumaResponse
};
pub
(
super
)
use
self
::{
args
::
Args
as
Ruma
,
response
::
RumaResponse
};
use
crate
::{
client
,
server
};
use
crate
::{
client
,
server
};
pub
type
State
=
Arc
<
service
::
Services
>
;
pub
fn
build
(
router
:
Router
<
State
>
,
server
:
&
Server
)
->
Router
<
State
>
{
pub
fn
build
(
router
:
Router
<
State
>
,
server
:
&
Server
)
->
Router
<
State
>
{
let
config
=
&
server
.config
;
let
config
=
&
server
.config
;
let
router
=
router
let
router
=
router
...
...
This diff is collapsed.
Click to expand it.
src/api/router/state.rs
0 → 100644
+
22
−
0
View file @
ccef1a4c
use
std
::{
ops
::
Deref
,
sync
::
Arc
};
use
conduit_service
::
Services
;
#[derive(Clone)]
pub
struct
State
{
services
:
Arc
<
Services
>
,
}
impl
State
{
pub
fn
new
(
services
:
Arc
<
Services
>
)
->
Self
{
Self
{
services
,
}
}
}
impl
Deref
for
State
{
type
Target
=
Arc
<
Services
>
;
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
self
.services
}
}
This diff is collapsed.
Click to expand it.
src/router/router.rs
+
1
−
1
View file @
ccef1a4c
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
pub
(
crate
)
fn
build
(
services
:
&
Arc
<
Services
>
)
->
Router
{
pub
(
crate
)
fn
build
(
services
:
&
Arc
<
Services
>
)
->
Router
{
let
router
=
Router
::
<
State
>
::
new
();
let
router
=
Router
::
<
State
>
::
new
();
let
state
=
services
.clone
();
let
state
=
State
::
new
(
services
.clone
()
)
;
conduit_api
::
router
::
build
(
router
,
&
services
.server
)
conduit_api
::
router
::
build
(
router
,
&
services
.server
)
.route
(
"/"
,
get
(
it_works
))
.route
(
"/"
,
get
(
it_works
))
...
...
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