blob: 9d2c40a3c2d90ab923fff36caefeef2eeb8125f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# dict2rest
A simple proxy service to provide an HTTP (REST) interface to a
[Dict protocol (RFC 2229)](http://tools.ietf.org/html/rfc2229) for the Dict
protocol. Written in Go.
An instance can _usually_ be access from
http://felixhanley.info/projects/lahu/dictionary/
## Installation
This project currently uses [gb](https://getgb.io) as its build tool. All
dependencies are in this repository.
Assuming you have `gb` installed it should be as simple as this:
```shell
git clone https://github.com/felix/go-dict2rest
cd go-dict2rest
gb build
./bin/dict2rest --dicthost dict.org
```
The server binary has the following options:
```
$ dict2rest --help
Usage of dict2rest:
-dicthost string
Dict server name (default "localhost")
-dictport string
Dict server port (default "2628")
-gzip
Enable gzip compression
-port string
Listen port (default "8080")
```
## Usage
The URL endpoints try to match the commands defined in RFC 2229. Results are
JSON and have the following format (newlines added for readability):
GET /databases
```json
[
{
"name":"eng-lhu",
"description":"English-Lahu Dictionary ver. 20160128"
}, {
"name":"lhu-eng",
"description":"Lahu-English Dictionary ver. 20160128"
}
]
```
GET /define/{word}
GET /define/{word}?dict=eng-lhu
```json
[
{
"dictionary":"WordNet (r) 3.0 (2006)",
"word":"lahu",
"definition":"Lahu\n n 1: a Loloish language\n"
}
]
```
Where 'eng-lhu' is one of the names of the server's dictionaries.
RFC 2229 error codes are passed through as JSON:
```json
{"code":552,"message":"no match"}
```
## TODO
- Add strategy listing and lookups
- Add server and status commands
- Add tests
## License
Copyright Felix Hanley, 2016
See LICENSE file.
|