Popularity
3.8
Growing
Activity
4.1
-
66
5
7

Programming language: Go
Tags: Server Applications     API     REST    
Latest version: v3.0

Simple CRUD App w/ Gorilla/Mux, MariaDB alternatives and similar packages

Based on the "Server Applications" category

Do you think we are missing an alternative of Simple CRUD App w/ Gorilla/Mux, MariaDB or a related project?

Add another 'Server Applications' Package

README

Simple CRUD App w/ Gorilla/Mux, MariaDB, Redis

Go Report Card CodeFactor

NOTE

This project is not longer maintained. I'll make a new better project.

Features

Basic CRUD operations (Create-Read-Update-Delete).

Database Scheme

Data table:

create table products
(
    id           int(11) unsigned auto_increment primary key,
    name         tinytext null,
    manufacturer tinytext null
);

You can generate data from http://filldb.info/.

Users table:

CREATE TABLE `users` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `username` text NOT NULL,
  `saltedpassword` text NOT NULL,
  `salt` text NOT NULL,
  PRIMARY KEY (`id`)
);

Password+Salt is encrypted with bcryptwith 10 rounds and stored in saltedpasswordcolumn.

Caching

You can edit cache time from this line:

err = a.Cache.Set(r.RequestURI, content, 10*time.Minute).Err()

Example Requests

To get all entries from table:

curl --user user1:pass1 127.0.0.1:8000/api/products/list

To get an entry with id (where id equals 10):

curl --user user1:pass1 127.0.0.1:8000/api/products/10

To create an entry:

curl --header "Content-Type: application/json" \
     --request POST \
     --data '{"name": "ABC", "manufacturer": "ACME"}' \
     --user user1:pass1 127.0.0.1:8000/api/products/new

To update an entry:

curl --request PUT \ 
     --data '{"name": "ABC", "manufacturer": "ACME"}' \ 
     --user user1:pass1 127.0.0.1:8000/api/products/11

To delete an entry:

curl --request DELETE --user user1:pass1 127.0.0.1:8000/api/products/10