Correct url for nodeinfo version (#4734)
* Correct url for nodeinfo version * add compat redirect --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
This commit is contained in:
parent
d8dc38eb06
commit
b2c1a14234
1 changed files with 6 additions and 4 deletions
|
@ -14,10 +14,12 @@ use url::Url;
|
||||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
cfg
|
cfg
|
||||||
.route(
|
.route(
|
||||||
"/nodeinfo/2.0.json",
|
"/nodeinfo/2.1.json",
|
||||||
web::get().to(node_info).wrap(cache_1hour()),
|
web::get().to(node_info).wrap(cache_1hour()),
|
||||||
)
|
)
|
||||||
.service(web::redirect("/version", "/nodeinfo/2.0.json"))
|
.service(web::redirect("/version", "/nodeinfo/2.1.json"))
|
||||||
|
// For backwards compatibility, can be removed after Lemmy 0.20
|
||||||
|
.service(web::redirect("/nodeinfo/2.0.json", "/nodeinfo/2.1.json"))
|
||||||
.route(
|
.route(
|
||||||
"/.well-known/nodeinfo",
|
"/.well-known/nodeinfo",
|
||||||
web::get().to(node_info_well_known).wrap(cache_3days()),
|
web::get().to(node_info_well_known).wrap(cache_3days()),
|
||||||
|
@ -27,9 +29,9 @@ pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
async fn node_info_well_known(context: web::Data<LemmyContext>) -> LemmyResult<HttpResponse> {
|
async fn node_info_well_known(context: web::Data<LemmyContext>) -> LemmyResult<HttpResponse> {
|
||||||
let node_info = NodeInfoWellKnown {
|
let node_info = NodeInfoWellKnown {
|
||||||
links: vec![NodeInfoWellKnownLinks {
|
links: vec![NodeInfoWellKnownLinks {
|
||||||
rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.0")?,
|
rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.1")?,
|
||||||
href: Url::parse(&format!(
|
href: Url::parse(&format!(
|
||||||
"{}/nodeinfo/2.0.json",
|
"{}/nodeinfo/2.1.json",
|
||||||
&context.settings().get_protocol_and_hostname(),
|
&context.settings().get_protocol_and_hostname(),
|
||||||
))?,
|
))?,
|
||||||
}],
|
}],
|
||||||
|
|
Loading…
Reference in a new issue