Skip to content

Commit

Permalink
Auto merge of #1912 - kzys:fastboot-install, r=jtgeibel
Browse files Browse the repository at this point in the history
Make /install work under FastBoot

Will add nginx.conf change after #1907. Early feedback is welcome!
  • Loading branch information
bors committed Dec 3, 2019
2 parents eea11cd + 976e8e8 commit 8f56f5f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/routes/crate/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { inject as service } from '@ember/service';

export default Route.extend({
flashMessages: service(),
redirector: service(),

redirect() {
let crate = this.modelFor('crate');

let documentation = crate.get('documentation');
if (documentation) {
window.location = documentation;
this.redirector.redirectTo(documentation);
} else {
// Redirect to the crate's main page and show a flash error if
// no documentation is found
Expand Down
3 changes: 2 additions & 1 deletion app/routes/crate/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { inject as service } from '@ember/service';

export default Route.extend({
flashMessages: service(),
redirector: service(),

redirect() {
let crate = this.modelFor('crate');

let repository = crate.get('repository');
if (repository) {
window.location = repository;
this.redirector.redirectTo(repository);
} else {
// Redirect to the crate's main page and show a flash error if
// no repository is found
Expand Down
5 changes: 4 additions & 1 deletion app/routes/install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default Route.extend({
redirector: service(),

redirect() {
window.location = 'https://doc.rust-lang.org/cargo/getting-started/installation.html';
this.redirector.redirectTo('https://doc.rust-lang.org/cargo/getting-started/installation.html');
},
});
15 changes: 15 additions & 0 deletions app/services/redirector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Service, { inject as service } from '@ember/service';

export default Service.extend({
fastboot: service(),

redirectTo(url) {
if (this.fastboot.isFastBoot) {
let headers = this.fastboot.response.headers;
headers.set('location', url);
this.set('fastboot.response.statusCode', 301);
} else {
window.location = url;
}
},
});

0 comments on commit 8f56f5f

Please sign in to comment.