godo-api

command module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

README

GoDo API

GoDo API was built to support the GoDo application, in providing a RESTful API.

Go Reference


Table of Contents


Getting Started

Docker

Quickly get started by using Docker to install the GoDo API.

docker-compose up -d db
docker-compose up --build -d server

Requirements

  • Go (to compile applications)
  • PostgreSQL

To do this, all you need is to have Go - the programming language - installed on your computer.

To edit the necessary variables to hook up GoDo API with a database. You will need to clone the GoDo API repository.

$ git clone github.com/rsHalford/godo-api

Then after making the necessary changes to the source code. Build the GoDo API binary, for the operating server it will be ran on.

$ env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build github.com/rsHalford/godo-api

This example command will build GoDo API to be executable on Debian 10.

Then you would need to have a web server installed and a way to run GoDo API as a daemon.

  • Apache2 (ProxyPass to your web address)
  • Systemd (daemonize GoDo API to run in the background)

These recommendations are based on what I found to work best for my setup.

Setting Up

To setup the server application, there a three changes that need to be made.

Authentication

To secure your todo list online, you will need to change the api_username and api_password variables, required to access the API endpoints. These variables are found in the config.yaml file.

These values will be what you send to the API with each request, using Basic Authentication.

An example of the config.yaml can be found in the project's repository

api_username: "username"
api_password: "password"

Currently GoDo API only supports PostgreSQL. To link up the server to a database, make sure to edit the config.yaml. Providing the db_username, db_password, name and port - relating to your database address.

db_username: "username"
db_password: "password"
name: "godo api"
port: "5432"
Server

GoDo API by default serves on port :8080. As an example, below is a basic Apache configuration file to relay GoDo API to your domain.

Apache Configuration Example:

<VirtualHost *:80>
        ServerName godo.example.com
        ServerAdmin webmaster@example.com
        ProxyRequests Off
        <Proxy *>
                Require all granted
        </Proxy>
        ProxyPass / http://127.0.0.1:8080/
        ProxyPassReverse / http:127.0.0.1:8080/
        ErrorLog ${APACHE_LOG_DIR}/godo-api-error.log
        CustomLog ${APACHE_LOG_DIR}/godo-api-access.log combined
</VirtualHost>
Daemonize

To have GoDo API run at all times in the background. You will need to make it run as a daemon. This is possible by creating one as a service with your init system - such as with systemd.

Systemd Service Example:

[Unit]
Description=GoDo API RESTful API

[Service]
ExecStart=/path/to/godo-api/excutable
WorkingDirectory=/path/to/godo-api
StandardOutput=journal
StandardError=inherit
SyslogIdentifier=godo-api
User=user
Group=group
Type=simple
Restart=on-failure

[Install]
WantedBy=multi-user.target

Licence

GoDo API is released under the GNU General Public License v3.0.

👉 See LICENSE.

Documentation

Overview

Copyright © 2021 Richard Halford <richard@xhalford.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL