Move to git.themmonk.com
This commit is contained in:
33
internal/httpserver/api/misc.go
Normal file
33
internal/httpserver/api/misc.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func RegisterMiscEndpoints() {
|
||||
http.HandleFunc("/opal", EndpointOpal)
|
||||
}
|
||||
|
||||
type endpointOpalResponse struct {
|
||||
ServerApi string
|
||||
ApiVersion string
|
||||
}
|
||||
|
||||
// GET /opal
|
||||
func EndpointOpal(w http.ResponseWriter, r *http.Request) {
|
||||
var ret endpointOpalResponse
|
||||
ret.ServerApi = "Opal"
|
||||
ret.ApiVersion = "0.0.1"
|
||||
|
||||
retJson, err := json.Marshal(ret)
|
||||
if err != nil {
|
||||
fmt.Println("API warning: failed to marshal /opal response")
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(retJson)
|
||||
}
|
||||
Reference in New Issue
Block a user