initial commit
Signed-off-by: Pin <Pin>
This commit is contained in:
33
handlers/apihandler.go
Normal file
33
handlers/apihandler.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"log"
|
||||
"dogapi/db"
|
||||
"encoding/json"
|
||||
"dogapi/structs"
|
||||
)
|
||||
|
||||
type Dog struct {
|
||||
Id string `json:"id"`
|
||||
Author string `json:"author"`
|
||||
Title string `json:"title"`
|
||||
Format string `json:"format"`
|
||||
Hash string `json:"hash"`
|
||||
Breed string `json:"breed"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
func APIHandler(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
var dogquery structs.DogPicRow
|
||||
dogquery = db.RandomSelect()
|
||||
log.Println(dogquery)
|
||||
var res Dog
|
||||
res.Id = "1"
|
||||
res.Author = "spencer"
|
||||
res.Title = "cool dog"
|
||||
json.NewEncoder(w).Encode(dogquery)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user