All Projects → marshallshen → instructions

marshallshen / instructions

Licence: other
Restful API microservice built with Golang and Gin

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Labels

Projects that are alternatives of or similar to instructions

openbrewerydb-rails-api
Official v1 Open Brewery DB REST API built with Ruby on Rails
Stars: ✭ 17 (-32%)
Mutual labels:  api-rest
cleanapi
Pretty tornado wrapper for making lightweight REST API services
Stars: ✭ 26 (+4%)
Mutual labels:  api-rest
cv4pve-api-php
Proxmox VE Client API for PHP
Stars: ✭ 45 (+80%)
Mutual labels:  api-rest
covidAPI
Coronavirus API for Current cases by country COVID-19
Stars: ✭ 600 (+2300%)
Mutual labels:  api-rest
vemdezapbe.be
Vem de zap bb 😏😊😂
Stars: ✭ 33 (+32%)
Mutual labels:  api-rest
go-api-boilerplate
Boilerplate for Golang API
Stars: ✭ 153 (+512%)
Mutual labels:  api-rest
smockin
Dynamic API, S3 & Mail mocking for web, mobile & microservice development.
Stars: ✭ 74 (+196%)
Mutual labels:  api-rest
Nigerian-states-api
An api for basic information about all 36 states in Nigeria
Stars: ✭ 26 (+4%)
Mutual labels:  api-rest
nuada-cli
Nuada CLI was designed to improve your development experience by using ExpressJS and Mongoose tools.
Stars: ✭ 19 (-24%)
Mutual labels:  api-rest
AniAPI
Core behind AniAPI HTTP Rest APIs.
Stars: ✭ 144 (+476%)
Mutual labels:  api-rest
The-Code-Bending-Dictionary
🧚🏽‍♀️ learn tech vocab in a friendly way 🧚🏽‍♀️ CONTRIBUTIONS WELCOME! 🔥
Stars: ✭ 19 (-24%)
Mutual labels:  api-rest
buscador-ao
Ponto de obtenção de informações públicas de Angola
Stars: ✭ 21 (-16%)
Mutual labels:  api-rest
FSharp.JsonApi
Use F# to create and consume flexible, strongly typed web APIs following the JSON:API specification
Stars: ✭ 20 (-20%)
Mutual labels:  api-rest
dart-express
Express-like HTTP framework written in Dart
Stars: ✭ 34 (+36%)
Mutual labels:  api-rest
Aweme-Kuaishou-Douyin
抖音大部分接口,以及快手的首页feed接口 soul app接口 nice app接口 毒app加签接口
Stars: ✭ 109 (+336%)
Mutual labels:  api-rest
laravel5-jokes-api-with-jwt-and-pagination
Laravel5 Full Fledged API with JWT auth
Stars: ✭ 15 (-40%)
Mutual labels:  api-rest
liuye
柳叶清单开放 API 文档
Stars: ✭ 32 (+28%)
Mutual labels:  api-rest
DummyJSON
DummyJSON provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend.
Stars: ✭ 213 (+752%)
Mutual labels:  api-rest
market place api 6
Code example of API on Rails 6 book https://github.com/madeindjs/api_on_rails
Stars: ✭ 18 (-28%)
Mutual labels:  api-rest
reky
Reky is an opensource API development platform. It automatically visualizes API response with outstanding graphs & tables.
Stars: ✭ 22 (-12%)
Mutual labels:  api-rest

Instructions

A simple RESTful API microservice in Go

Prerequisites

  1. Go Language 1.8 or later.

  2. MySQL Server 5.7.

You can run MySQL in a docker container as follows.

We will set some environment variables that will help us to run our MySQL server container and we will also leverage these environment variables when we run our microservice.

export MYSQL_CONTAINER_NAME=mysql_instruct # relabel as appropriate
export MYSQL_ROOT_PASSWORD=root_password # replace as appropriate
export MYSQL_DATABASE=instructions
export MYSQL_USER=instruct
export MYSQL_PASSWORD=instruct_password # replace as appropriate

To run our MySQL Server:

docker run \
  --name=${MYSQL_CONTAINER_NAME} \
  -d \
  -e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
  -e MYSQL_DATABASE=${MYSQL_DATABASE} \
  -e MYSQL_USER=${MYSQL_USER} \
  -e MYSQL_PASSWORD=${MYSQL_PASSWORD} \
  -p 3306:3306 \
  mysql/mysql-server:5.7

Install App

  1. Clone the repo.
  2. Install Go package dependencies
go get github.com/gin-gonic/gin
go get gopkg.in/gorp.v1
go get github.com/go-sql-driver/mysql

Testing App

go test

Run App

  1. Start Go app locally
go run main.go
  1. Play with instruction endpoints
  • Create a new instruction
curl \
  -i \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{ "event_status": "83", "event_name": "100" }' \
  http://localhost:8080/api/v1/instructions
  • Show an existing instruction
curl -i http://localhost:8080/api/v1/instructions/1
  • Show all existing instructions
curl -i http://localhost:8080/api/v1/instructions
  • Delete an existing instructions
curl -i -X DELETE http://localhost:8080/api/v1/instructions/1
  • Update an existing instructions
curl \
  -i \
  -X PUT \
  -H "Content-Type: application/json" \
  -d '{ "event_status": "83", "event_name": "100" }' \
  http://localhost:8080/api/v1/instructions/1

Run App with Docker

Make sure Docker is installed before executing the command below

docker build -t instructions-app . # inside the app directory

Cleanup

  1. Press CTRL-C to stop the application.

  2. Stop MySQL Server if you started it using Docker.

docker stop ${MYSQL_CONTAINER_NAME}
docker rm ${MYSQL_CONTAINER_NAME}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].