small update with some improvements, updated readme

This commit is contained in:
arnaucode
2018-04-15 21:21:55 +02:00
parent 9bd5a48bcc
commit 9ecec88e7d
27 changed files with 58 additions and 16 deletions

Binary file not shown.

View File

@@ -13,12 +13,15 @@ import (
"github.com/gorilla/mux"
)
//PadModel is the data structure for each pad
type PadModel struct {
Link string `json:"link"`
Dir string `json:"dir"`
Title string `json:"title"`
IpfsHash string `json:"ipfsHash"`
}
//Repo contains all the pads --currently not used--
type Repo struct {
Pads []string `json:"pads"`
}
@@ -37,6 +40,7 @@ func main() {
log.Fatal(http.ListenAndServe(":"+config.Port, router))
}
//GetReposList is the endpoint to get the list of current repos
func GetReposList(w http.ResponseWriter, r *http.Request) {
file, err := os.Open(padArchiver.Storage)
if err != nil {
@@ -56,6 +60,7 @@ func GetReposList(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, string(jResp))
}
//GetRepoIDList is the endpoint to get one repo by id
func GetRepoIDList(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
repoid := vars["repoid"]
@@ -74,6 +79,8 @@ func GetRepoIDList(w http.ResponseWriter, r *http.Request) {
check(err)
fmt.Fprintln(w, string(jResp))
}
//PostStorePad is the endpoint to post the signal to store one pad
func PostStorePad(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
repoid := vars["repoid"]

View File

@@ -5,6 +5,7 @@ import (
"io/ioutil"
)
//Config is the configuration of the API server
type Config struct {
Port string `json:"port"`
}