forked from TripwireTeam/tripwire
root endpoint and startup logs
This commit is contained in:
parent
b03aa46c00
commit
e7cc5f4ba7
3 changed files with 28 additions and 1 deletions
15
endpoints.go
15
endpoints.go
|
@ -6,6 +6,19 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func rootEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
sendJSON(w, YggdrasilInfo{
|
||||
Status: "OK",
|
||||
RuntimeMode: "productionMode",
|
||||
AppAuthor: "Tripwire Team",
|
||||
AppDescription: "Custom Yggdrasil authentication server",
|
||||
SpecVersion: "5.2.0",
|
||||
AppName: "tripwire.yggdrasil",
|
||||
ImplVersion: "5.2.0",
|
||||
AppOwner: "Who knows?",
|
||||
})
|
||||
}
|
||||
|
||||
func authenticateEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
var authPayload AuthPayload
|
||||
err := unmarshalTo(r, &authPayload)
|
||||
|
@ -140,7 +153,7 @@ func invalidateEndpoint(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func registerEndpoints(r *mux.Router) {
|
||||
r.HandleFunc("/", notFoundStub)
|
||||
r.HandleFunc("/", rootEndpoint)
|
||||
r.HandleFunc("/authenticate", authenticateEndpoint).Methods("POST")
|
||||
r.HandleFunc("/refresh", refreshTokenEndpoint).Methods("POST")
|
||||
r.HandleFunc("/signout", signoutEndpoint).Methods("POST")
|
||||
|
|
3
main.go
3
main.go
|
@ -19,8 +19,11 @@ func handleRequests() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
log.Println("Tripwire initializing...")
|
||||
initDB()
|
||||
|
||||
log.Println("Tripwire started.")
|
||||
|
||||
handleRequests()
|
||||
|
||||
defer DB.Close()
|
||||
|
|
11
types.go
11
types.go
|
@ -41,6 +41,17 @@ type UserCredentials struct {
|
|||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type YggdrasilInfo struct {
|
||||
Status string `json:"Status"`
|
||||
RuntimeMode string `json:"Runtime-Mode"`
|
||||
AppAuthor string `json:"Application-Author"`
|
||||
AppDescription string `json:"Application-Description"`
|
||||
SpecVersion string `json:"Specification-Version"`
|
||||
AppName string `json:"Application-Name"`
|
||||
ImplVersion string `json:"Implementation-Version"`
|
||||
AppOwner string `json:"Application-Owner"`
|
||||
}
|
||||
|
||||
type NotFoundError struct{}
|
||||
|
||||
func (m *NotFoundError) Error() string {
|
||||
|
|
Loading…
Reference in a new issue