Documentation ¶
Index ¶
- func HeartbeatHandler(w http.ResponseWriter, r *http.Request)
- func StringArrayContains(arr []string, str string) bool
- type APIRoute
- type APIServer
- func (s *APIServer) AddAuthorizedRemote(remote string)
- func (s *APIServer) AddRoute(route *APIRoute)
- func (s *APIServer) GetAuthorizedRemotes() []string
- func (s *APIServer) GetCertFolder() string
- func (s *APIServer) GetPort() string
- func (s *APIServer) GetRouter() *mux.Router
- func (s *APIServer) GetServer() *http.Server
- func (s *APIServer) Initialize(port string, certFolder string)
- func (s *APIServer) Start()
- func (s *APIServer) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HeartbeatHandler ¶
func HeartbeatHandler(w http.ResponseWriter, r *http.Request)
HeartbeatHandler checks the health of the service. For simplicity, we'll just send an "OK" response.
func StringArrayContains ¶
StringArrayContains helper function to return true or false is a given string exists in the provided string array
Types ¶
type APIRoute ¶
type APIRoute struct { Version uint8 // 0 = v1, 1 = v2, etc. SubRoute string // e.g. "users", "posts","products", etc. Name string // e.g. "get", "create", "update", "delete", etc. Method string // e.g. "GET", "POST", "PUT", "DELETE", etc. Handler func(http.ResponseWriter, *http.Request) // e.g. GetUsersHandler, CreateUsersHandler, etc. }
APIRoute is a struct to represent an API route.
type APIServer ¶
type APIServer struct {
// contains filtered or unexported fields
}
APIServer is a struct to represent the API server.
var ( // Server is the global value for the API server Server *APIServer )
func (*APIServer) AddAuthorizedRemote ¶
AddAuthorizedRemote adds an authorized remote to the API server.
func (*APIServer) AddRoute ¶
AddRoute adds a route to the API server. Example:
Server.AddRoute(&APIRoute{ version: 1, subRoute: "users", name: "get", method: "GET", handler: GetUsersHandler, })
func (*APIServer) GetAuthorizedRemotes ¶
GetAuthorizedRemotes returns the list of authorized remotes (IP Addresses).
func (*APIServer) GetCertFolder ¶
GetCertFolder returns the path to the TLS certificates.
func (*APIServer) Initialize ¶
startServer starts the HTTP/2 server in a goroutine.
Click to show internal directories.
Click to hide internal directories.