summaryrefslogblamecommitdiff
path: root/api/main.go
blob: c4645b863133779435d0062a040b361ff559db5e (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                               

                                              





























                                                                     
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)
}