forked from firka/firka
Adds a standalone Go mock server (mock_kreta_server/) with an admin GUI for editing student/grade/timetable/etc data, plus a login-screen long-press toggle to point the app at it instead of the real e-Kréta service for local testing. Also pulls in updated translations from the firka-localization submodule.
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func writeJSON(w http.ResponseWriter, v any) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(v)
|
|
}
|
|
|
|
func (s *Server) handleGetStudent(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetStudent())
|
|
}
|
|
|
|
func (s *Server) handleGetClassGroups(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetClassGroups())
|
|
}
|
|
|
|
func (s *Server) handleGetNoticeBoard(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetNotices())
|
|
}
|
|
|
|
func (s *Server) handleGetInfoBoard(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetInfoBoard())
|
|
}
|
|
|
|
func (s *Server) handleGetGrades(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetGrades())
|
|
}
|
|
|
|
func (s *Server) handleGetClassGroupAverages(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetAverages())
|
|
}
|
|
|
|
func (s *Server) handleGetTimeTable(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetLessons())
|
|
}
|
|
|
|
func (s *Server) handleGetOmissions(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetOmissions())
|
|
}
|
|
|
|
func (s *Server) handleGetHomework(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetHomework())
|
|
}
|
|
|
|
func (s *Server) handleGetTests(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetTests())
|
|
}
|
|
|
|
func (s *Server) handleGetDktSubjects(w http.ResponseWriter, r *http.Request) {
|
|
writeJSON(w, s.store.GetDktSubjects())
|
|
}
|