mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
Refactor apiTest into Status.go
This commit is contained in:
@@ -21,8 +21,15 @@ import (
|
||||
// Router can be used to register additional API functions
|
||||
var Router *mux.Router
|
||||
|
||||
// WSUpgrader can be used to provide web sockets. It uses all default options and allows all requests.
|
||||
var WSUpgrader = websocket.Upgrader{}
|
||||
// WSUpgrader is used for websocket functionality. It allows all requests.
|
||||
var WSUpgrader = websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
// allow all connections by default
|
||||
return true
|
||||
},
|
||||
}
|
||||
|
||||
// Start starts the API. ListenAddresses is a list of IP:Ports
|
||||
func Start(ListenAddresses []string, UseSSL bool, CertificateFile, CertificateKey string, TimeoutRead, TimeoutWrite time.Duration) {
|
||||
@@ -30,10 +37,6 @@ func Start(ListenAddresses []string, UseSSL bool, CertificateFile, CertificateKe
|
||||
return
|
||||
}
|
||||
|
||||
WSUpgrader.CheckOrigin = func(r *http.Request) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
Router = mux.NewRouter()
|
||||
|
||||
Router.HandleFunc("/test", apiTest).Methods("GET")
|
||||
@@ -107,8 +110,3 @@ func DecodeJSON(w http.ResponseWriter, r *http.Request, data interface{}) (err e
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func apiTest(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ import (
|
||||
"github.com/PeernetOfficial/core"
|
||||
)
|
||||
|
||||
func apiTest(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
}
|
||||
|
||||
type apiResponseStatus struct {
|
||||
Status int `json:"status"` // Status code: 0 = Ok.
|
||||
IsConnected bool `json:"isconnected"` // Whether connected to Peernet.
|
||||
|
||||
Reference in New Issue
Block a user