Skip to content
Snippets Groups Projects
Commit 6f355598 authored by Hans Kristian Hoel's avatar Hans Kristian Hoel
Browse files

set up limit and aut for language

parent 20ab3a14
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ package assignment2
import (
"encoding/json"
"log"
"net/http"
"strconv"
)
......@@ -14,6 +15,11 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
URL1 := "https://git.gvk.idi.ntnu.no/api/v4/projects"
Client := http.DefaultClient
auth := QueryGet("auth", "false", r)
if auth != "false" {
L.Auth = true
}
resp := DoRequest(Client, w, URL1)
err := json.NewDecoder(resp.Body).Decode(&I)
......@@ -34,9 +40,14 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
}
// limit := QueryGet("limit", "5", r)
limit := QueryGet("limit", "5", r) // gets limit for localhost link
TempInt, err := strconv.Atoi(limit) // turns sting to int
if err != nil { // check for error
log.Fatal(err)
}
// auth := QueryGet("auth", "false", r)
L.Languages = L.Languages[:TempInt] // sets how many lauguages gets posted
http.Header.Add(w.Header(), "Content-Type", "application/json") // makes the print look good
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment