summaryrefslogtreecommitdiff
path: root/api/main.go
blob: c4645b863133779435d0062a040b361ff559db5e (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
43
44
package api

import (
	"fmt"
	"net/http"

	redqdb "sinanmohd.com/redq/db"
)

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

	login := newLogin(db)
	http.Handle(prefix+"/ac/login", login)
	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)
}