I saw this post: Hosting web applications on OpenWrt
But I'm struggling to find a way to actually point openWRT endpoint towards my Go script. For example, the instructions he provided said once you compile you can just curl the IP address. Does anyone know how to set this up with Uhttpd/Lighttpd? Or do I not need them to be able to host this API?
Tldr: How should I setup a basic API with GoLang on OpenWRT?
Your go application does serve the http requests itself, no need for an additional http server.
Write the go code for you api or what ever as in your linked example, cross compile it and run it. Then you can access this http endpoint with any http client, for example curl.
That's really interesting I didn't think it could sevrve the http requests itself. I thought it was simialr to Lua/Php which needs a http server & fastcgi config.
Also, to have this part of my OS I assume I just need to add the app to the bootscript to have it running permanently as an API?
Go isn't a script language like php, it's a programming language that compiles to assembly binaries like with c/c++.
While you can add it to /etc/rc.local to start at boot up, it has many advantages to create a dedicated init script for it.
Take a look hete how this works on OpenWrt:
Perfect thanks so much Juppin, this clears up a lot for me!
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.