diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-04-06 03:00:22 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-04-06 03:00:22 +0700 |
| commit | db5b35cd5052d47c81bb63f78f7781513be22fd2 (patch) | |
| tree | c393a2aa937a0b576a9f25c10b76dd8967a90b02 /server.go | |
| parent | 5ea27bffa9020ddcdc62774a29e399e76ae5997c (diff) | |
| download | kamusku-db5b35cd5052d47c81bb63f78f7781513be22fd2.tar.xz | |
www-kbbi: add content page for "/project/kbbi"
The content page show the definition and capabilities of the API.
Diffstat (limited to 'server.go')
| -rw-r--r-- | server.go | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -12,6 +12,7 @@ import ( "sync" "time" + "github.com/shuLhan/share/lib/debug" "github.com/shuLhan/share/lib/http" ) @@ -44,9 +45,14 @@ type Server struct { // func NewServer(kamusStorage string) (server *Server, err error) { opts := &http.ServerOptions{ + Root: "_content", Address: defListen, } + if debug.Value > 0 { + opts.Development = true + } + server = &Server{ stopped: make(chan bool, 1), } @@ -78,7 +84,7 @@ func NewServer(kamusStorage string) (server *Server, err error) { // Start the HTTP server. // func (server *Server) Start() (err error) { - go server.dumpCache() + go server.dumpCacheJob() server.wg.Add(1) return server.http.Start() @@ -88,7 +94,7 @@ func (server *Server) Start() (err error) { // Shutdown the HTTP server and save the cache for future use. // func (server *Server) Shutdown() (err error) { - err = server.Shutdown() + err = server.http.Shutdown(nil) server.stopped <- true @@ -134,6 +140,8 @@ func (server *Server) handleDefinisi( httpReq *stdhttp.Request, reqBody []byte, ) (resBody []byte, err error) { + httpRes.Header().Set(headerNameACAO, "*") + paramKata := httpReq.Form.Get(paramNameKata) if len(paramKata) == 0 { return []byte(emptyResponse), nil |
