Skip to content

harkamals/golang-restful-json-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restful JSON API

Change Log
# Version 3
  + TLS, http redirect
  + Middleware for Logging
  + Middleware for API Auth - WIP
  + GORM for database models
 
# Version 2
  + Orders model
  + Use postgresql as database backend
  + Testing
  ~ Refactoring
    Viper for configuration mgmt
 
# Version 1
  + Initial release
  + In-memory 'todo' app model
Perform Tests
# Run Tests
go test -v
Generate Self-signed certs
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem
Start web server
# Run example 
go run main.go
REST Endpoints
# Database backend
curl http://localhost:8080/orders
curl http://localhost:8080/order/1
curl -H "Content-Type: application/json" -d '{"name":"New Order"}'  http://localhost:8080/order
 
# In-memory
curl http://localhost:8080/todos
curl http://localhost:8080/todos/1
curl -H "Content-Type: application/json" -d '{"name":"New Todo"}'  http://localhost:8080/todos

Releases

No releases published

Packages

No packages published

Languages