summaryrefslogtreecommitdiff
path: root/api/main.go
blob: 29f71c9ff10bf3ddb795524f5406eb72277254d8 (plain) (blame)
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
38
39
40
41
42
package api

import (
	"fmt"
	"net/http"

	redqdb "sinanmohd.com/redq/db"
)

func Run(db *redqdb.SafeDB) {
	const prefix string = "POST /_redq/api"

	exampleApi := newExamplApiName(db)
	http.Handle(prefix+"/example", exampleApi)

	http.HandleFunc("GET /{$}", home)
	http.ListenAndServe(":8008", nil)
}

func home(rw http.ResponseWriter, r *http.Request) {
	const index string = `
		<!DOCTYPE html>
		<html lang="en">
			<head>
				<meta charset="UTF-8">
				<title>🚨 redq</title>
			</head>
			<body>
				<center>
					<h1 style="font-size: 10em">
						redq is active
					</h1>
					<p style="font-weight: bold">
						we're soo back 🥳
					</p>
				</center>
			</body>
		</html>
	`

	fmt.Fprint(rw, index)
}