Browse Source

implemented server handler to serve websites by alias

pull/1/head
Vincent Truchseß 10 months ago
parent
commit
3b47fa0f70
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      src/saljut/server.clj

+ 11
- 1
src/saljut/server.clj View File

@@ -2,7 +2,8 @@
(:require [ring.adapter.jetty :as jt]
[clojure.string :as st]
[saljut.util.server :as us]
[saljut.macros :as m])
[saljut.macros :as m]
[saljut.util.codec :as c])
(:gen-class))

(defn handler [request]
@@ -27,6 +28,15 @@
:body (new java.io.FileInputStream file)})
;; Handle domain.alias.ssb hostnames
#"^([a-zA-Z0-9]+\.){2}ssb$"
(let [[domain al] (st/split hostname #"\.")
ids (us/alias-lookup al)]
(if (= 1 (count ids))
(recur (assoc-in request [:headers "host"]
(str domain "."
(c/convert-64-32-key (first ids)) ".b32.ssb")))
{:status 200
:headers {"ContentType" "text/html"}
:body "The alias was not unique!"}))
{:status 200
:headers {"ContentType" "text/html"}
:body "Going to perform a key-lookup"}


Loading…
Cancel
Save