Skip to content

theeldarka/first-golang-test-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test Task in Go

You have 1 hour to solve the task. If you are lucky enough and have time left, please try to optimise your solution or highlight some edge cases.

Description

  1. You should create a handler which sends how many days left until 1 Jan 2025 and response with HTTP 200 OK status code.
  2. Build a middleware, which checks HTTP header User-Role presents and contains admin and prints red button user detected to the console (using default log package or any 3rd party) if so.

Think about coding standards and best practices.

In general, the task is about providing a working solution, but if you have time to create a good code-structure, we'd love it!

Thanks, @spatecon for the task!

Run solution

docker run -p 8090:1323 theeldarka/first-golang-test-task:latest

Go to http://localhost:8090

Let's check the middleware:

curl http://localhost:8090 --header User-Role:\ Super-Admin

Then, look at the console logs

{"time":"2023-01-29T21:38:59.080717517Z","level":"WARN","prefix":"-","file":"middleware.go","line":"14","message":"red button user detected"}