Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Logger ¶
func Logger(inner http.Handler) http.HandlerFunc
Logger is a decorator for a HTTP Request, adding logging functionality
func NotFound ¶
func NotFound(w http.ResponseWriter, r *http.Request)
NotFound is a 404 Message according to the Response type
func SendErrorJSON ¶
func SendErrorJSON(w http.ResponseWriter, s int, m string)
Types ¶
type Bird ¶
type Bird struct { ID int `json:"id" bson:"id"` Name string `json:"name" bson:"name"` Genus string `json:"genus" bson:"genus"` Species string `json:"species" bson:"species"` TitleDE string `json:"title_de" bson:"title_de"` TitleEN string `json:"title_en" bson:"title_en"` DescDE string `json:"desc_de" bson:"desc_de"` DescEN string `json:"desc_en" bson:"desc_en"` }
Bird defines a single Bird to retrieve info about
type Response ¶
type Response struct { Status int `json:"status"` Message string `json:"message"` Count int `json:"count"` Data interface{} `json:"data"` }
Response defines an API response.
func NewResponse ¶
NewResponse returns a Response with a passed message string and slice of Data. This will automatically set the Status field to 200.
func (Response) SendJSON ¶
func (r Response) SendJSON(w http.ResponseWriter)
SendJSON encodes a Response as JSON and sends it on a passed http.ResponseWriter.
type Route ¶
type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc }
Route is a helper type defining a specific Route
type Server ¶
Server defines holds information about routing and the Database sessions. Since all routes hang off the Server, handlers can easily access the database session.
func (*Server) DetectBinary ¶
func (s *Server) DetectBinary() http.HandlerFunc
DetectBinary takes a application/octet-stream file via POST requests and forwards it to the API for detection
func (*Server) Dummy ¶
func (s *Server) Dummy() http.HandlerFunc
Dummy sends a test Response mit randomized IDs and accuracies
func (*Server) GetAllBirds ¶
func (s *Server) GetAllBirds() http.HandlerFunc
GetAllBirds returns all Bird info from the database, without descriptions. This needs to be limited with more birds (200+).
func (*Server) GetBirdByID ¶
func (s *Server) GetBirdByID() http.HandlerFunc
GetBirdByID Retrieves a single Bird from the database.
func (*Server) Ping ¶
func (s *Server) Ping() http.HandlerFunc
Ping sends a simple "Pong" as as JSON response