├── README.md ├── init └── init.go ├── app.yaml ├── .gitmodules ├── .gitignore ├── info ├── time_test.go └── time.go └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | ImosAPI (Private Use) 2 | ===================== 3 | 4 | ImosAPI is an AppEngine service providing imos' APIs. 5 | -------------------------------------------------------------------------------- /init/init.go: -------------------------------------------------------------------------------- 1 | package init 2 | 3 | import ( 4 | "github.com/imos/imosrpc" 5 | ) 6 | 7 | func init() { 8 | http.HandleFunc("/", imosrpc.DefaultHandler()) 9 | } 10 | -------------------------------------------------------------------------------- /app.yaml: -------------------------------------------------------------------------------- 1 | application: imos-api 2 | version: 1 3 | runtime: go 4 | api_version: go1 5 | automatic_scaling: 6 | max_idle_instances: 1 7 | min_pending_latency: 1.0s 8 | 9 | handlers: 10 | - url: /.* 11 | script: _go_app 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "github.com/imos/imosrpc"] 2 | path = github.com/imos/imosrpc 3 | url = https://github.com/imos/imosrpc 4 | [submodule "github.com/imos/imosql"] 5 | path = github.com/imos/imosql 6 | url = https://github.com/imos/imosql 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /info/time_test.go: -------------------------------------------------------------------------------- 1 | package infoapi_test 2 | 3 | import ( 4 | "github.com/imos/imosrpc" 5 | "github.com/imos/infoapi" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func init() { 11 | imosrpc.SetHostname(imosrpc.InternalHostname) 12 | } 13 | 14 | func TestTime(t *testing.T) { 15 | currentTime := time.Now() 16 | apiTime := infoapi.Time() 17 | if apiTime.Before(currentTime) || apiTime.After(time.Now()) { 18 | t.Errorf("Time returns a wrong time: %s.", apiTime) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /info/time.go: -------------------------------------------------------------------------------- 1 | package infoapi 2 | 3 | import ( 4 | "github.com/imos/imosrpc" 5 | "time" 6 | ) 7 | 8 | func init() { 9 | imosrpc.RegisterHandler("info/time", TimeHandler) 10 | } 11 | 12 | type TimeRequest struct{} 13 | 14 | type TimeResponse struct { 15 | CurrentTime time.Time `json:"current_time"` 16 | } 17 | 18 | func TimeHandler(request TimeRequest) TimeResponse { 19 | return TimeResponse{CurrentTime: time.Now()} 20 | } 21 | 22 | func Time() time.Time { 23 | request := TimeRequest{} 24 | response := TimeResponse{} 25 | imosrpc.Call("info/time", request, &response) 26 | return response.CurrentTime 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Kentaro IMAJO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------