Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
assignment1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathilde Hertaas
assignment1
Commits
777eac01
Commit
777eac01
authored
2 months ago
by
Mathilde Hertaas
Browse files
Options
Downloads
Patches
Plain Diff
updatet infromation in README and information on homepage
parent
c1c7aa02
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+2
-0
2 additions, 0 deletions
README.md
handelers/homeHandler.go
+7
-2
7 additions, 2 deletions
handelers/homeHandler.go
handelers/konstanter.go
+5
-1
5 additions, 1 deletion
handelers/konstanter.go
main.go
+2
-2
2 additions, 2 deletions
main.go
with
16 additions
and
5 deletions
README.md
+
2
−
0
View file @
777eac01
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
handelers/homeHandler.go
+
7
−
2
View file @
777eac01
...
...
@@ -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}"
,
},
},
}
...
...
This diff is collapsed.
Click to expand it.
handelers/konstanter.go
+
5
−
1
View file @
777eac01
...
...
@@ -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
This diff is collapsed.
Click to expand it.
main.go
+
2
−
2
View file @
777eac01
...
...
@@ -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
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment