diff options
| author | Christine Dodrill <me@christine.website> | 2019-06-15 20:51:21 -0400 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2019-06-15 20:51:21 -0400 |
| commit | 101cd28dc37249efd4f61c0d21d4d9d1f2272d0b (patch) | |
| tree | 488b8e448d5a6eeaf94c2312a1e004a85f22aa0b /cmd | |
| parent | 598268d233e69586bcc5886fff149b506dc496e5 (diff) | |
| download | x-101cd28dc37249efd4f61c0d21d4d9d1f2272d0b.tar.xz x-101cd28dc37249efd4f61c0d21d4d9d1f2272d0b.zip | |
add jvozba to johaus and polyglot
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/johaus/main.go | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/cmd/johaus/main.go b/cmd/johaus/main.go index 4b43d2a..092cd69 100644 --- a/cmd/johaus/main.go +++ b/cmd/johaus/main.go @@ -8,6 +8,7 @@ import ( "log" "net/http" + "git.xeserv.us/xena/jvozba" "within.website/johaus/parser" _ "within.website/johaus/parser/camxes" "within.website/johaus/pretty" @@ -24,18 +25,38 @@ func main() { log.Printf("Listening on http://0.0.0.0:%s", *port) - http.DefaultServeMux.HandleFunc("/tree", tree) - http.DefaultServeMux.HandleFunc("/braces", braces) + http.HandleFunc("/tree", tree) + http.HandleFunc("/braces", braces) + http.HandleFunc("/lujvo", lujvo) http.ListenAndServe(":"+*port, nil) } +func lujvo(w http.ResponseWriter, r *http.Request) { + data, err := ioutil.ReadAll(r.Body) + if err != nil { + http.Error(w, "can't read: "+err.Error(), http.StatusBadRequest) + return + } + defer r.Body.Close() + + jvo, err := jvozba.Jvozba(string(data)) + if err != nil { + http.Error(w, "can't read: "+err.Error(), http.StatusBadRequest) + return + } + + w.Header().Set("X-Content-Language", "jbo") + http.Error(w, jvo, http.StatusOK) +} + func braces(w http.ResponseWriter, r *http.Request) { data, err := ioutil.ReadAll(r.Body) if err != nil { http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) return } + defer r.Body.Close() tree, err := parser.Parse(*dialect, string(data)) if err != nil { @@ -57,6 +78,7 @@ func tree(w http.ResponseWriter, r *http.Request) { http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest) return } + defer r.Body.Close() tree, err := parser.Parse(*dialect, string(data)) if err != nil { |
