Skip to content
Snippets Groups Projects
Commit 777eac01 authored by Mathilde Hertaas's avatar Mathilde Hertaas
Browse files

updatet infromation in README and information on homepage

parent c1c7aa02
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ Henter informasjon om et land basert på en 2-bokstavs landkode (ISO 3166-2).
```sh
http://localhost:8080/countryinfo/v1/info/{country_code}{?limit=10}
```
* limit er en valgfri parameter som gir en begrenisng på antall byer som vises med valgt land (Default er 10 stykker)
* Metode: GET
* Eksempel: http://localhost:8080/countryinfo/v1/info/NO?limit=4
......@@ -40,6 +41,7 @@ Hente populasjonsdata om et land basert på en 2-bokstavs landkode (ISO 3166-2).
```sh
http://localhost:8080/countryinfo/v1/population/{country_code}{?startyear-endYear}
```
* startYear-endYear er en valfri parameter som gir begreninger på spesifikke år du får populasjonsdata fra (Default er alle tilgjengelige år)
* Metode: GET
* Eksempel: http://localhost:8080/population/NO?limit=2010-2015
......
......@@ -10,17 +10,22 @@ import (
func HomeHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
response := map[string]interface{}{
"WELCOME": "Welcome to the Country Info API",
WELCOME: WELCOME_MESSAGE,
"endpoints": map[string]interface{}{
"Get Country Info": map[string]string{
"Description": "Get country details including cities, population, and more.",
"URL Format": "http://localhost:8080/countryinfo/v1/info/{country_code}{?limit=10}",
"URL Format": "http://localhost:8080/countryinfo/v1/info/{ISO_3166-2_country_code}{?limit=10}",
"Example": "http://localhost:8080/countryinfo/v1/info/NO?cities=5",
},
"Get status info" : map[string]string{
"Description" : "Get information about the API statuses",
"URL" : "http://localhost:8080/status/",
},
"Get population info" : map[string]string{
"Description" : "Get information about countries and their population",
"URL" : "http://localhost:8080/countryinfo/v1/population/{ISO_3166-2_country_code}{?startYear-endYear}",
"Example": "http://localhost:8080/countryinfo/v1/population/NO?2010-2015}",
},
},
}
......
......@@ -10,4 +10,8 @@ const SLASH_DEFAULT = "/"
//ERRORS
//Terminal info
const RUNNING_ON_PORT = ""
\ No newline at end of file
const RUNNING_ON_PORT = ""
//User information
const WELCOME = "WELCOME"
const WELCOME_MESSAGE = "Welcome to the Country Info API"
\ No newline at end of file
......@@ -19,8 +19,8 @@ func main() {
http.HandleFunc(handelers.INFO_DEFAULT, handelers.CountryInfoHandler)
http.HandleFunc(handelers.POPULATION_DEFAULT, handelers.PopulationHandler)
if err := http.ListenAndServe(":8080", nil); err != nil {
fmt.Printf("Server failed to start: %s\n", err)
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment