Skip to content

Commit

Permalink
refactor(examples): remove concat uses
Browse files Browse the repository at this point in the history
  • Loading branch information
dwisiswant0 committed Sep 5, 2023
1 parent c62990a commit c2c43fd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions examples/demo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build:
go build -ldflags '-s -w' -o demo .
4 changes: 2 additions & 2 deletions examples/demo/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## demo

Run from root project directory
Run from this directory

```bash
$ go run examples/demo/*.go
$ go run .
```

To build
Expand Down
5 changes: 0 additions & 5 deletions examples/demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"

"net/http"
"path/filepath"

"github.com/kitabisa/teler-waf"
"gitlab.com/golang-commonmark/mdurl"
Expand All @@ -17,10 +16,6 @@ type Data struct {
ReqId string
}

func concat(path string) string {
return filepath.Join("examples", "demo", path)
}

func myHandler(w http.ResponseWriter, r *http.Request) {
data := Data{Query: mdurl.Decode(r.URL.RawQuery), Body: r.FormValue("body")}
index.Execute(w, data)
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package main

import "text/template"

var index = template.Must(template.ParseFiles(concat("index.html")))
var ouch = template.Must(template.ParseFiles(concat("403.txt")))
var index = template.Must(template.ParseFiles("index.html"))
var ouch = template.Must(template.ParseFiles("403.txt"))
2 changes: 1 addition & 1 deletion examples/demo/var.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package main

import "net/http"

var static = http.FileServer(http.Dir(concat("static")))
var static = http.FileServer(http.Dir("static"))

0 comments on commit c2c43fd

Please sign in to comment.