Skip to content
This repository was archived by the owner on Jan 23, 2022. It is now read-only.

Commit 57ee649

Browse files
committed
Remove iris
1 parent 97bb86b commit 57ee649

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
DOR - Domain Ranker
55
-------------------
66

7-
Fast HTTP service (build on top of amazing
8-
[iris framework](https://github.com/kataras/iris)) which shows a specified
9-
domain rank from following providers:
7+
Fast HTTP service which shows a specified domain rank from following providers:
108
- [Alexa](https://www.alexa.com/topsites)
119
- [Majestic](https://blog.majestic.com/development/alexa-top-1-million-sites-retired-heres-majestic-million/)
1210
- [Umbrella OpenDNS](https://umbrella.cisco.com/blog/2016/12/14/cisco-umbrella-1-million/)
@@ -53,10 +51,8 @@ Or if you want just in-memory database:
5351
dor-web-inmemory -h
5452
5553
Usage of dor-web-inmemory:
56-
-host string
57-
IP-address to bind (default "127.0.0.1")
58-
-port string
59-
Port to bind (default "8080")
54+
-listen string
55+
Listen address to bind (default "127.0.0.1:8080")
6056
```
6157

6258
## Docker usage

web/web.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
package dorweb
22

33
import (
4+
"encoding/json"
45
"log"
6+
"net/http"
57

68
"github.com/ilyaglow/dor"
7-
"github.com/kataras/iris"
9+
"github.com/julienschmidt/httprouter"
810
)
911

1012
// Serve represents a web interaction with the DomainRank
1113
func Serve(address string, d *dor.App) {
12-
app := iris.New()
13-
app.Get("/rank/{domain:string}", func(ctx iris.Context) {
14-
r, err := d.Find(ctx.Params().Get("domain"))
14+
router := httprouter.New()
15+
router.GET("/rank/:domain", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
16+
result, err := d.Find(ps.ByName("domain"))
1517
if err != nil {
16-
ctx.StatusCode(iris.StatusBadRequest)
17-
} else {
18-
ctx.JSON(r)
18+
http.Error(w, err.Error(), http.StatusBadRequest)
19+
return
1920
}
20-
})
2121

22-
log.Fatal(app.Run(iris.Addr(address), iris.WithCharset("UTF-8")))
22+
enc := json.NewEncoder(w)
23+
if err := enc.Encode(result); err != nil {
24+
http.Error(w, err.Error(), http.StatusInternalServerError)
25+
}
26+
})
27+
log.Fatal(http.ListenAndServe(address, router))
2328
}

0 commit comments

Comments
 (0)