Skip to content

Web server exercise that exposes endpoints for array sorting and user info. display

Notifications You must be signed in to change notification settings

jcalvarezj/jikko-golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jikko-Golang

This small project is an HTTP web server on port 8080 that exposes endpoints for the purpose of exercise. Includes API documentation with Swag exposed on /swagger

Requirements

A MySQL database server should be running locally with a jikkodb database, which should have the user table and a jikkouser user identified by jikkopass. It is possible to import the jikkodb.sql script on the jikkodb database to create and fill the user table.

Compilation and Execution

Run go build to compile, and then ./jikko-golang to run the server

Alternatively, use go run main.go

After adding more API docs remember to use swag init -g main.go before build/execution to update the documentation

Endpoints

/swagger/index.html

Presents API documentation for the other endpoints

/arrays

This endpoint serves POST requests with the following JSON body:

{
	"unsorted": [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
}

This should give a 200-status JSON response of

{
	"unsorted": [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],
	"sorted": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
}

If there is any missing or incorrect data, it will return a 400 status code with the message:

Incorrect or missing data in request body

/users

This endpoint serves either GET/POST requests, responding with an HTML page that displays a form to search user by id, and lists all the users in the database below

/users/{id}

This endpoint serves either GET/POST requests, responding with an HTML page that displays the user detail page for the user identified by the provided index id (integer) as a URL parameter