Please enable JavaScript.
Coggle requires JavaScript to display documents.
Packt - Building RESTful webservice in Go - Coggle Diagram
Packt - Building RESTful webservice in Go
Handling Routing
Basic ServeMux: http.NewServeMux()
httprouter package
Gorilla Mux
SQL Injection prevention
user level permission to various tables
careful observe the url pattern
HTMLEsccapeString
Binding with database driver
Turn off database debug config on production
sqlmap
Middleware
What Midlleware can do?
Logging
Authentication
Throttle
Transformer
Request filter
Basic middleware: write a function which receive http.Handler and return http.Handler, e.g return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
Alice package to handle middleware for you
Gorilla package middleware
LoggingHandler
CompressionHandler
RecoveryHandler
RPC
basic net/rpc
gorilla RPC
go-restful package for fast build API
Storage
SQLite
Mongodb
PostgreSQL
Protocol Buffer
Simpler
3~10 time smaller against JSON/XML
20~30 faster against JSON/XML
less ambiguous
generated data class easy to programming
gRPC
GORM
CommandLine App
flag package
HTTP Client
gRequest package
Microservice
GoKit package
Logging
Instrumentation
Deploying
Nginx
API Gateway
Nginx
Kong
Use case of API Gateway
Security
Authentication
Logging
Traffic Control
Transformation
Rate Limit
Expose API
authentication from known hosts
as a service
Authentication
Session based
Token based
JWT token
Bearer Token (OAuth2)