go-restful-api-example

command module
v0.0.0-...-07a8822 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: MIT Imports: 1 Imported by: 0

README

Go RESTful API Example

Prerequisite

  • Installed Go
  • Installed MySQL Database
  • Create database with name go_restful_api

Run Application

$ go main.go

APIs Example

Register User

$ curl -X POST 'localhost:8080/users' \
-H 'Content-Type: application/json' \
-d '{
	"username":"[username here]",
	"email":"[email address here]",
	"password":"[password here]"
}'

Get All Users

$ curl -X GET 'localhost:8080/users'

Get User By Id

$ curl -X GET 'localhost:8080/users/[id here]'

Login

$ curl -X POST 'localhost:8080/login' \
-H 'Content-Type: application/json' \
-d'{
	"email":"[email address here]",
	"password":"[password here]"
}'

Update User

$ curl -X PUT 'localhost:8080/users/1' \
-H 'Authorization: bearer [jwt token here]' \
-H 'Content-Type: application/json' \
-d '{
    "username" : "[new username here]",
    "email" : "[new email here]",
    "password" : "[new password here]"
}'

Delete User

$ curl -X DELETE 'localhost:8080/users/1' \
-H 'Authorization: bearer [jwt token here]'

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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