Closed whatsdis closed 8 years ago
this.route("apis", {path: "/apis/:apiUrl", controller: "ApiController"});
Router.map(function () {
this.route("home_public", {path: "/", controller: "HomePublicController"});
this.route("login", {path: "/login", controller: "LoginController"});
this.route("register", {path: "/register", controller: "RegisterController"});
this.route("forgot_password", {path: "/forgot_password", controller: "ForgotPasswordController"});
this.route("reset_password", {path: "/reset_password/:resetPasswordToken", controller: "ResetPasswordController"});
this.route("projects", {path: "/projects", controller: "ProjectsController"});
this.route("projects.main", {path: "/projects/main/:projectId/:fileId", controller: "ProjectsMainController"});
this.route("projects.main.editor", {path: "/projects/main/:projectId/:fileId/editor", controller: "ProjectsMainEditorController"});
this.route("projects.insert", {path: "/projects/insert", controller: "ProjectsInsertController"});
this.route("projects.edit", {path: "/projects/edit/:projectId", controller: "ProjectsEditController"});
this.route("admin", {path: "/admin", controller: "AdminController"});
this.route("admin.users", {path: "/admin/users", controller: "AdminUsersController"});
this.route("admin.users.details", {path: "/admin/users/details/:userId", controller: "AdminUsersDetailsController"});
this.route("admin.users.insert", {path: "/admin/users/insert", controller: "AdminUsersInsertController"});
this.route("admin.users.edit", {path: "/admin/users/edit/:userId", controller: "AdminUsersEditController"});
this.route("user_settings", {path: "/user_settings", controller: "UserSettingsController"});
this.route("user_settings.profile", {path: "/user_settings/profile", controller: "UserSettingsProfileController"});
this.route("user_settings.change_pass", {path: "/user_settings/change_pass", controller: "UserSettingsChangePassController"});
this.route("logout", {path: "/logout", controller: "LogoutController"});
this.route("apis", {path: "/apis/:apiUrl", controller: "ApiController"});
});
and I've got all the necessary files in the api/ folder, api.html, apiController.js, api.js
returns 404.
@whatsdis you need apiUrl in your URL, so localhost:3000/apis
will not work, but localhost:3000/apis/anything
will work.
If you want apiUrl
to be optional, then you need to define it with question mark:
this.route("apis", {path: "/apis/:apiUrl?", controller: "ApiController"});
in that case, both: localhost:3000/apis
and localhost:3000/apis/anything
will work.
BTW, just guessing - if your apis
route should expose server-side only API (API is usually without GUI, that's why I believe you need that), then you can define it as server-side route. In meteor kitchen you can do it by setting application.server_side_routes
, or directly in generated app like this:
Somewhere under /server/
directory:
Router.map(function () {
this.route("apis", {path: "/apis/:apiUrl?", controller: "ApisController", where: "server"});
});
(see meteor-kitchen source code: https://github.com/perak/kitchen-site/blob/master/meteor-kitchen.json#L964 there are two server side routes).
@perak no actually wasn't making it a server side thing, apis/ just a page that displays list.
when i navigate to /apis/test, it just shows a blank page, inspecting the elements doesn't seem to show the expected html.
<template name="Api">
<div class="page-container container" id="content">
<div class="row" id="title_row">
<div class="col-md-12">
test
</div>
</div>
</div>
</template>
Your template should be named "Apis" not "Api" (unless you specify different in route definition or in controller. And do you have controller? Also, do you have any errors in console when you navigate to that url?
will give that a try
yup that did it! thanks again @perak!
:+1:
so I created a route along with all the other routes there by default, created a controller, but when I navigate to it, I get 404.