Apache access the server_rec for a module - c

I want to get at the value in server_rec.module_config. Does request_rec have any sort of reference to the server_rec? I am not seeing one in the httpd.h file but I could be missing it.
Basically I want to access the configuration file for the module while in my handler and I know I can do that with ap_get_module_config(). However I don't think request_rec.request_config or request_rec.per_dir_config store what I need.
Help is appreciated! And yes I have looked through the Apache guide to making modules (found here).

After more looking around I finally managed to come across it.
In the request_rec there is a variable called server which is a server_rec*. So to access the config file you would use
ap_get_module_config(r->server->module_config, &my_module)
where r is the request_rec passed into the handler.

Related

reload module without restart server

good day!
i have small question about reload c module in tarantool
for example: i have c module which expose a method:
int calculate(lua_State* L);
in addition i declared entry point:
extern "C"
{
LUA_API int luaopen_cuendemodule(lua_State *L);
}
now, i load this module ("testmodule.so") in tarantool:
require('testmodule')
box.schema.func.create('testmodule.calculate')
box.schema.user.grant('user', 'execute', 'function', 'testmodule.calculate')
and now i call this method from my c# client:
await tarantoolClient.Call<TarantoolTuple<CalculateParameters>, CalculationResults>("testmodule.calculate", TarantoolTuple.Create(....));
and it is work as expected - method calculate executed and results was returned
but if i want ะตั‰ update my module than the problems begin: after i replace so file and call calculate method my tarantool restart and i can see something like "tarntool invalid opcode in testmodule.so" in dmesg
after reading documentation i see additional parameters in function definition like this:
box.schema.func.create('testmodule.calculate', {language = 'C'})
but after this if i call it from c# i receive exception with message "failed to dynamically load function undefined symbol calculate"
i use tarantool 1.7 on ubuntu
my so compiled with gcc 8.1.0
There is no a good way to do this (means - a portable way). I think, the best way is using something like dlopen()[1], the function allows to open (manage shared objects in general) a shared object, but you have to be very cautious about this, it may fail your code as well or even you can have sigfault.
A good example is: https://github.com/tarantool/mqtt, the module does not use these functions (func.create and so on), but it could be extended as well.
So the point is: if you develop a C-module, you have to think about reloading policy.
For instance, *-unix like systems have alot of features which allows to reload some shared objects and also tarantool has some features too.
And also, I suggest to you, start think about modules as like about Lua's C-modules, it is actually the same.
PS
Some reload modules also available: https://github.com/Mons/tnt-package-reload (I didn't test the module), https://github.com/tarantool/reload (I didn't test the module)
[1] http://man7.org/linux/man-pages/man3/dlopen.3.html
I think, you can try this module for reload your application -https://github.com/moonlibs/package-reload.

Method 'DUMPSETSET_GET_ENTITYSET' not implemented in data provider class

I created a function module and gateway service that reads data from SNAP_BEG table which is stores DUMP issues. There is no any error except that.
When I try to use link as /DumpsetSet I get
"Method 'DUMPSETSET_GET_ENTITYSET' not implemented in data provider class"
I found that how to redefine implementation but what code should I write in it? I cant find an example for this. Function module code is.
SELECT * FROM SNAP_BEG INTO TABLE ET_SNAP_BEG.
Or I just need to use something else?
What type of link should I use. I got one more project someoneelse done and I cant see difference in implementation from mine.
Edit: I can get firs record that program find by /DumpsetSet('username'). But it is not giving me all datas anyway.
Did you map the GetEntitySet to a data source from SEGW - SAP Gateway Service Builder, under the Service Implementation part. After this operation you should generate runtime objects.
There is a good blog for this, here.

Ng2-Admin-using exists components

I am new to angular 2/4,and I am trying to use ng2-admin as a base, and trying to build on to of it a full dash board includes beck-end.
I am facing lots of issues while trying to use exist component(such as basic table) in a new simple module. I can't find any detailed documentation on ng2-admin beside creating new page.
Is there anyone who can guide me please?
Thanks
Never mind, i found the solution ๐Ÿ˜€
what actually i did was to redefine the Declarations/Providers correctly.
when using "ng" to generate new things,it is also adding unnecessary deceleration in some places so this was my first mistake,also some used providers/services was needed to be declared on the right module.after understanding how the structure should be ,i kept the rules and i was able to add what i needed without any issues.

Resolving relative $resource path in Angular 1.5

My Angular 1.5.8 web application is at http://www.example.com/foo/ and my RESTful list of bars is at http://www.example.com/foo/api/bars. When ui-router goes to the list of bars in Angular, my browser is at http://www.example.com/foo/#/bars. I simply want to connect to a RESTful resource to connect to http://www.example.com/foo/api/bars using HTTP GET.
So I try the most obvious thing:
$resource("api/bars/")
In my mind that should resolve api/bars/ to the current path http://www.example.com/foo/#/bars to give me http://www.example.com/foo/api/bar, right? But it doesn't work (even though I could swear it worked with $http). Instead it gives me a $resource:badcfg error.
Angular lets me do the following, but this doesn't produce the correct path, instead giving me http://www.example.com/api/bars:
$resource("/api/bars/")
So I try $browser.baseHref(), but that seems to be set to the empty string (why?), producing http://www.example.com/api/bars again.
$resource($browser.baseHref() + "/api/bars/")
I tried to use $location.path(), but Angular thinks I want the path after the hash sign, so that doesn't work, giving me http://www.example.com/bars/api/bars. Doh!
$resource($location.path() + "/api/bars/")
How can I simply resolve api/bars/ to the base path of the current URL http://www.example.com/foo/#/bars, producing http://www.example.com/foo/api/bars (or even just the path)?
Note that it is not acceptable for me to hard code an absolute path, or to change my HTML code. Why should I? Besides, this application will be mounted at two places on the same server (hey, it's easy with Java, Tomcat, and JAX-RS), at http://www.example.com/foo/ and http://www.example.com/foo-demo/. The application should run unmodified under each location, accessing the RESTful API list of bars at http://www.example.com/foo/api/bars and http://www.example.com/foo-demo/api/bars, respectively.
This is not complicated; this is simple "URI syntax 101" which has been outlined in RFCs for over two decades. I simply want to resolve api/bars/ to the base path of the current URL http://www.example.com/foo/#/bars. How do I do that in Angular 1.5?
OK, there's two ways to do this. If you absolutely want an absolute path, you can use this:
$resource(location.origin + location.pathname + "api/bars/")
Note the use of the location object location.origin to establish the protocol, domain, and port; and location.pathname to establish the base path. (Once again Microsoft will throw a wrench into the works: location.origin doesn't work on IE11 on some versions of Windows 10.)
But the better approach is simply to use:
$resource("api/bars")
"Wait, I thought you said that this will give you an error!" you might exclaim. Well it turns out I was wrong about that. I was indeed getting an error, but it was because I hadn't set the Accept header to ask for JSON, and the plain/text response I was getting (that's the default on my RESTful resource) was confusing $resource. It turns out that a relative URI will work after all.
It is possible to use relative-path syntax for $resource as you can use it with $http which is used by $resource. This can be done by omitting the leading slash (as you suggested) or by prefixing the resource with ./.
Your badcfg error seems more likely to be the case because your request works out correctly but the server response does not match the expectations. So probably you are returning a single object instead of an array. Please use the dev tools to debug what is really returned from the server.
See the docs on $resource for details.

How to access current request from bootstrap?

Is it possible to access the current request in Kohana's bootstrap? I tried accessing Request::$current but $current doesn't seem to be defined at that stage. Is there any way around that? Also at what point in the application is Request::$current defined?
It's not possible, because Request object is created in index.php after including bootstrap.php:
// Bootstrap the application
require APPPATH.'bootstrap'.EXT;
/**
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
* If no source is specified, the URI will be automatically detected.
*/
$request = Request::factory();
If you must access it, do it in the index.php after it has been created, although maybe you could tell us what exactly are you trying to do?
You can use it after Kohana initialization.
Kohana::init(...);
Also, good practice is using interface methods instead of public variable. I'm wondering why the developers keep $current as a public field.
So.. use
Request::current();
Also, It seems that using
Request::initial();
is better idea. But it depends on your realization.

Resources