-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
37 lines (31 loc) · 1.59 KB
/
server.go
File metadata and controls
37 lines (31 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"encoding/base64"
"fmt"
"net/http"
"time"
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
welcomeMessage := "Welcome to the DevOps challenge! This is your opportunity to showcase your expertise in automation, networking and security. Whether you are an experienced DevOps professional or just starting out, this challenge will test your ability to work in a fast-paced and dynamic environment. Your task will be to demonstrate your skills in the areas of infrastructure management, deployment and automation, network security, and system performance. So, are you ready to take on this challenge and prove that you're a true DevOps professional?"
fmt.Fprintln(w, welcomeMessage)
}
func challengeHandler(w http.ResponseWriter, r *http.Request) {
currentTime := time.Now()
currentYear := currentTime.Year()
encoded := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("/devops%d", currentYear)))
message := fmt.Sprintf("Congratulations again! Now go to %s to start your final challenge.", encoded)
fmt.Fprintln(w, message)
}
func finalHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Congratulations you pass the last test! This is a template of a DevOps test using Docker. Project: https://github.com/giovannirossini/devops-test.")
}
func main() {
currentTime := time.Now()
currentYear := currentTime.Year()
page := fmt.Sprintf("/devops%d", currentYear)
http.HandleFunc("/", indexHandler)
go http.ListenAndServe(":8080", nil)
http.HandleFunc("/challenge", challengeHandler)
http.HandleFunc(page, finalHandler)
http.ListenAndServe(":8573", nil)
}