Coder Social home page Coder Social logo

mrtkp9993 / simplecrudapp Goto Github PK

View Code? Open in Web Editor NEW
72.0 5.0 13.0 60 KB

Simple CRUD Application with Go, Gorilla/mux, MariaDB, Redis.

License: GNU General Public License v3.0

Go 100.00%
golang golang-application crud-application crud rest-api backend mariadb gorilla-mux redis

simplecrudapp's Introduction

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

simplecrudapp's People

Contributors

mrtkp9993 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.