- Served at path
/helloworld/go/
GET
API- Routed at
/helloworld/go/
- Returns a
text/plain
response containing Hello World!
-
POST
API -
Routed at
/helloworld/go/adder
-
Request body example:
POST /helloworld/go/adder application/json { "a": 523, "b": 10 }
-
JSON
response body example:200 OK application/json { "sha256": "fb8a0d2da8683cec6cc64542f95ae11e085c72d56c744b2be5be335295976610" }
-
GET
API -
Routed at
/helloworld/go/write
-
request example:
GET /helloworld/go/write?line=40
-
response example:
200 OK text/plain Line 40 : This is just a sample text
-
Build the server:
go build main.go
-
Systemd service configuration is available at
/os/helloworld-go.service
-
In the mentioned file, change
<path/to/go/executable/directory>
to absolute path of directory containingmain
executable file, and<path/to/go/executable>
to absolute path ofmain
executable file -
Save the service file at
/lib/systemd/system/helloworld-go.service
-
Enable the service:
> sudo systemctl enable helloworld-go
-
start the service:
> sudo systemctl start helloworld-go
-
Now, the server is listening on
0.0.0.0:8080
-
Add proxy config to Nginx server as bellow:
location /helloworld/go { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8080; }
-
Restart Nginx service:
> sudo systemctl restart nginx
- Full Nginx config is available at
/nginx/nginx-server-config