I have a Phalcon Multimodule App with the following structure:
appServer
apps
api
backend
web
config
public
The backend module is my common logic module. (I think that) I need a Controller in the API to call a Controller inside backend. How can I do that? or is there a better way to access the logic within the backend module from the api module?
I have already tried adding the \AppServer\Backend\Controllers namespace to the loader inside \AppServer\Api\Module->registerAutoloaders(), but when I tried to use it inside \AppServer\Api\Controllers\IndexController->index(), it gives me an error saying it couldn't find the class.
I've read that I should get the processed module from the router, but I don't know how to do that either.
Thanks in advance for your help :)
Use this structure:
appServer
apps
api
backend
web
common
models
controllers
views
config
public
Here is an example application that uses a similar application structure: https://github.com/phalcon/album-o-rama
Related
I am using ABP v3.3 on ASP.NET Core 3.1 in a microservice environment.
We are wanting to prefix our microservice routes with the service name.
E.g, accounting service would be:
/accounting/api/invoices
/accounting/api/payments
This is fine with our own controllers as we can define the route with route attributes. E.g [Route("accounting/api/invoices")]
However for internal abp routes like
/api/abp/api-definition
where the controller is defined in the Abp module with these route attributes already applied, how do we go about adding this prefix?
I can’t find anywhere in the documentation anything relating to this, except for the case of conventional controller creation which is not applicable here.
The above is to support the scenario where all microservices are behind an internal load balancer, and all /accounting routes should forward to this single service. This is troublesome currently when using IHttpClientProxy for service-to-service requests, as the /api/abp/api-definition request needs to be forwarded to the specific microservice.
The only alternative approach I have found is to set root paths for all services as http://<loadbalancer>/<servicename>, and then in each service add the line
app.UsePathBase("/accounting")
which strips the above path from the requests to enable route matching.
This however does cause additional issues with the generated Swagger docs from showing this additional route path, which can become confusing.
Any help appreciated
yes but not recommended because you need to replace several code parts.
for example
https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs#L94
https://github.com/abpframework/abp-samples/blob/master/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs#L126
https://github.com/abpframework/abp/blob/dev/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs#L14
I'm trying to create a nuxtJS module to make some changes to the routes based on the URL or request, i simply want to access the request.header.host inside a nuxtJS module but I'm unable to get it, i tried to check it process.server, this, context but unable to get the request object, i just want to get the full domain only, so how can I do that?
You can only get the hostname in the Browser JavaScript not internally in running nuxt app. As for nuxt app, it is running locally on the server (for example http://localhost:8080).
The information regarding hostname is present in services like Nginx/Apache.
Solution (One of them):
Use #nuxt/dotenv and store hostname in the environment variables:
hostname=example.com
then use wherever you want in your nuxt application with process.env.hostname
I have a Web Forms app that I created a few months ago and I added a Web API controller. I tried to use the 'automatic' routing that I saw in a presentation recently, but all I got was a 404. Then I tried to add routing for the Web API controller in my Global.asax using MapHttpRoute, as I've seen in several tutorials. However, even after adding Imports System.Web.Http to the file, the project will not recognize RouteTable.Routes.MapHttpRoute() I have tried adding other namespaces and ensuring that I have all the necessary Nuget packages, but I still am unable to set up routing for the Web API controller. Does anyone have a recommendation of where to start?
If anyone has this same issue in C# read on.
I am also using a web forms app and set the routing through the Global.asax file. For me Intellisense was 100% correct and it would not build regardless. To get this to work I had to add the following using directives.
using System.Web.Http;
and
using System.Web.Routing;
Becareful not to use using System.Web.Http.Routing by accident. This wont work.
You should add the reference to System.Web.Http.WebHost assembly and make sure you have
using System.Web.Http;
Why ? MapHttpRoute is defined in two assemblies, in System.Web.Http:
public static System.Web.Http.Routing.IHttpRoute MapHttpRoute(
this System.Web.Http.HttpRouteCollection routes, string name, string routeTemplate)
Member of System.Web.Http.HttpRouteCollectionExtensions
and in System.Web.Http.WebHost
public static Route MapHttpRoute(
this RouteCollection routes, string name, string routeTemplate, object defaults);
First one is an Extension on HttpRouteCollection
Second one is an Extension on RouteCollection
So when you have a webforms app, your Routes are defined in a RouteCollection so you need the WebHost version.
Its because architecture allowing WebApi to be hosted also out of IIS. see Hosting WebApi
I found this thread, which indicates that IntelliSense apparently has a problem with this, but if you type something like the following, it will build and run:
RouteTable.Routes.MapHttpRoute("MyApi", "api/{controller}")
I've just created two new webforms apps (one using .NET 4, the other 4.5), did nothing more than add web api via nuget and it worked.
What version of ASP.NET is your app running in? If you're running ASP.NET WebForms 2.0/3.5 then it's not supported.
Here's a tutorial which demonstrates how to add Web API to your Web Forms app - http://www.asp.net/web-api/overview/creating-web-apis/using-web-api-with-aspnet-web-forms
I have the same case, I solved by creating the api controller, when you add the
api controller VS will load all required refrences.
I am new to Yii. I have a jquery file manager working with plain PHP script. Now i want to integrate it with Yii Application. The flow is like, from index it will initiate jquery function, which will search for PHP connector script. My problem is, how can i include connector script in Yii so that the Jquery can access it
If you've got the rest of the extension working, then you can create a controller within this extension's directory to handle any actions for it. Then you can use the URL rules in the configuration to send specific URLs to it.
as of now i did not create any extensions, I put the connector script under assets directory and it just worked fine. I am sure this cannot be the best practice. I would like to get help on creating custom extensions for Yii
I'm trying to do a Symfony2 centric application and re-use all the Bundles for the web front app. The application will be divided in three API, FrontEnd, BackEnd, so that we can code the API like a Service Bundle and use it across the hole application and also will provide an API for our application. The FrontEnd will use the API as a Service and it will have all the front for user use. And the BackEnd will also use the API but providing a different url to admin the app.
This is the structure I'm using:
/app_api
/app_frontend
/app_backend
/bin
/src
/vendor
/web_api
/web_frontend
/web_backend
This will be traduced to:
api.domain.com (app_api, web_api)
www.domain.com (app_frontend, web_frontend)
backend.domain.com (app_backend, web_backend)
What do you think?
Is this posible?
What about performance, even if we are using APC?
If you have another solution let me know.
Thanks & Regards to everyone