Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeFromJSON(r *http.Request, data interface{}) error
- func NewSubRouter(routes Routes) *mux.Router
- func RespondWithJSON(w http.ResponseWriter, r *http.Request, status int, data interface{})
- func SendToService(service, method, endpoint string, query url.Values, body interface{}) (*http.Response, error)
- type Config
- type Course
- type Courses
- type Department
- type Departments
- type Faculty
- type FacultyDesignation
- type FacultyMember
- type HerculesDB
- type Room
- type Rooms
- type Route
- type Routes
- type Server
- type Service
- type Slot
- type Slots
- type Time
- type TimeSlot
- type Timetable
- type TimetableSlot
- type TimetableSlots
Constants ¶
const ( TableInsertionDepartments = `INSERT INTO departments (code, name) VALUES ($1, $2);` TableInsertionFacultyDesignations = `INSERT INTO faculty_designations (designation) VALUES ($1) RETURNING id;` TableInsertionFaculty = `INSERT INTO faculty (name, designation, department) VALUES ($1, $2, $3);` TableInsertionCourses = `INSERT INTO courses (code, name, credits, department) VALUES ($1, $2, $3, $4) RETURNING id;` TableInsertionRooms = `INSERT INTO rooms (room) VALUES ($1) RETURNING id;` TableInsertionCourseFaculty = `INSERT INTO course_faculty (faculty, course) VALUES ($1, $2)` TableInsertionCourseSlots = `INSERT INTO course_slots (slot, course) VALUES ($1, $2)` TableInsertionCourseRooms = `INSERT INTO course_rooms (room, course) VALUES ($1, $2)` TableInsertionSlots = `INSERT INTO slots (slot) VALUES ($1) RETURNING id;` TableInsertionTimeSlots = `INSERT INTO time_slots (time, slot) VALUES ($1, $2);` )
Table Insertion statements
const ( TableReadDepartment = `SELECT id FROM departments WHERE code=$1;` TableReadDesignation = `SELECT id FROM faculty_designations WHERE designation=$1;` TableReadFaculty = `SELECT id FROM faculty WHERE name=$1;` TableReadSlots = `SELECT id FROM slots WHERE slot=$1;` TableReadRooms = `SELECT id FROM rooms WHERE room=$1;` TableReadCourses = `SELECT id FROM courses WHERE code=$1;` )
Table querying statements given the id
const VERSION = "/api/v1"
Variables ¶
var ErrCourseNotFound = errors.New("The specified course was not found in the database.")
var ErrDataEncoding = errors.New("Unable to encode the data for you")
var ErrNotImplemented = errors.New("This feature has not yet implemented!")
Functions ¶
func DecodeFromJSON ¶
DecodeFromJSON is the common function to be used by all the POST handlers for reading JSON data from the request body and performing input validation.
func NewSubRouter ¶
func RespondWithJSON ¶
func RespondWithJSON(w http.ResponseWriter, r *http.Request, status int, data interface{})
RespondWithJSON is the common function to be used by all the handlers while returning JSON data to the caller.
Types ¶
type Config ¶
type Config struct { Database string `required:"true" desc:"Connection String, for more info see: https://godoc.org/github.com/lib/pq"` Port string `envconfig:"PORT" default:"8080" desc:"Application listen port"` }
Config represents configuration environment to running application
type Course ¶
type Course struct { Name string `json:"name"` Code string `json:"code"` Credits int `json:"credits"` }
Course denotes the information related to each course.
type Department ¶
type Department struct { ID string `json:"-"` // DO NOT EXPORT IDs, ever, for now. Name string `json:"name"` Code string `json:"code"` }
Department represents the metadata related to a department.
type Departments ¶
type Departments []Department
Departments represents the response returned by the DepartmentsHandler.
type Faculty ¶
type Faculty []FacultyMember
Faculty represents the response returned by the FacultyHandler.
type FacultyDesignation ¶
type FacultyDesignation string
FacultyDesignation represents the designation of a Faculty member.
type FacultyMember ¶
type FacultyMember struct { Name string `json:"name"` Department Department `json:"department"` Designation FacultyDesignation `json:"designation"` }
FacultyMember represents the information related to a faculty member at IIT KGP.
type HerculesDB ¶
HerculesDB represents the interface that needs to be satisfied by the database layer in order to work with the application API.
type Server ¶
type Server interface { http.Handler HerculesDB GetName() string GetURL() string }
Server represents the fundamental components of the API. Every service needs to implement this interface.
type Time ¶
type Time struct { // TODO: Use time.Weekday Day string `json:"day"` // TODO: Use time.Time Time string `json:"time"` }
Time represents a possible time for scheduling class.
type Timetable ¶
type Timetable struct { Monday TimetableSlots `json:"Monday"` Tuesday TimetableSlots `json:"Tuesday"` Wednesday TimetableSlots `json:"Wednesday"` Thursday TimetableSlots `json:"Thursday"` Friday TimetableSlots `json:"Friday"` }
type TimetableSlot ¶
type TimetableSlots ¶
type TimetableSlots []TimetableSlot