func StatusPingHandler(c echo.Context) error { err := database.GetConnection().Session.Ping() if err == nil { return c.String(http.StatusOK, "OK") } return c.String(http.StatusInternalServerError, "ERROR") }
func FilesGetHandler(c echo.Context) error { // Create the User Session session := session.NewSession(c) // Validate that the request signature is valid session.ValidateFileRequest() redirect := false if !session.AuthFailed { // Get the endpoint for that record endpoint := session.GetEndpoint() if plugin.CheckPlugin("get_file", endpoint) { plugin.RunPlugin("get_file", endpoint, session) } else { // Get the ID of the record that owns the file record_id := bson.ObjectIdHex(session.GetParam("record_id").(string)) // Get the record from the endpoint collection record := endpoint.FindReadRecordById(record_id, session.User) // Check if the record exists if record.Id != bson.ObjectId("") { // Get the ID of the file file_id := bson.ObjectIdHex(session.GetParam("file_id").(string)) // Get the file from the database file := record.FindFileById(file_id) // Validate that the file exists if file.Id != bson.ObjectId("") { // Redirect to the file path c.Redirect(301, file.DownloadURL()) redirect = true // Log the request session.LogRequest() } } if !redirect { session.Write() } } } return nil }