gravity icon indicating copy to clipboard operation
gravity copied to clipboard

Http support

Open jamesalbert opened this issue 6 years ago • 6 comments

I'm not sure if http support is better implemented built-in or through a library, but it's a generally useful feature.

I took a stab at handling get requests (super ugly, just got an mvp going)

https://github.com/jamesalbert/gravity/commit/2695e5b24bd663e0957598c21472006d19ab737f

Are there already plans to implement something like this? If not, with some feedback, is this something that can be added to the project?

jamesalbert avatar Jun 17 '19 07:06 jamesalbert

There was someone planning to work on passing features from a single-header socket library to Gravity.

Fortunately, making a wrapper for a library towards Gravity is not that difficult - but it does involve reading through the various headers, since not all functions are labeled very well (take the marry_* functions and macros for instance, which do array handling).

But for that, you do get a very low-level access to Gravity and values, reducing the layers of abstractions quite some and making access to the wrapper itself quite fast.

I was looking into Swig, but trying to write a wrapper generator using Swig is all but easy unfortunately...

IngwiePhoenix avatar Jun 17 '19 07:06 IngwiePhoenix

@IngwiePhoenix is there a wrapper on github I can use for reference? I tried looking, but gravitational spams the search + it seems there are still open issues for module support

jamesalbert avatar Jun 17 '19 07:06 jamesalbert

https://github.com/marcobambini/gravity/blob/master/src/optionals/gravity_env.c https://github.com/marcobambini/gravity/blob/master/src/optionals/gravity_env.h

This is one that I contributed. In general, you can find some good examples within the optionals folder.

IngwiePhoenix avatar Jun 17 '19 07:06 IngwiePhoenix

Oh, I saw those. That's what I modeled my changes off of

jamesalbert avatar Jun 17 '19 07:06 jamesalbert

And yes - module support is in fact still missing. But with module support, people mean something like this:

import x from "y";
var x = require("y");

But you can still add functions to Gravity just fine.

IngwiePhoenix avatar Jun 17 '19 07:06 IngwiePhoenix

think my link was poorly placed, fixed it

jamesalbert avatar Jun 17 '19 07:06 jamesalbert