Documentation ¶
Overview ¶
Package service provides a gae service instance framework on top of github.com/speedland/go/web package.
Using this package, what you need to do in your GAE app looks like this:
// app.go func init(){ s := service.New("serviceKey") s.Get("/path/to/endpoint/", web.HandlerFunc(...)) // register /serviceKey/path/to/endpoint handler ... s.Run() }
Index ¶
- Variables
- func NewHTTPClient(ctx context.Context) (c *http.Client)
- func WithContext(ctx context.Context, s *Service) context.Context
- type BuiltInAPIConfig
- type Cron
- type Service
- func (s *Service) AddCron(path, time, desc string, handlers ...web.Handler)
- func (s *Service) AddPushQueue(name string) *taskqueue.PushQueue
- func (s *Service) AsyncTask(path string, taskConfig *asynctask.Config)
- func (s *Service) Delete(path string, handlers ...web.Handler)
- func (s *Service) GenCronYAML(w io.Writer)
- func (s *Service) GenQueueYAML(w io.Writer)
- func (s *Service) Get(path string, handlers ...web.Handler)
- func (s *Service) GetCrons() []*Cron
- func (s *Service) GetQueues() []*taskqueue.PushQueue
- func (s *Service) GetTasks() []*Task
- func (s *Service) Key() string
- func (s *Service) Namespace() string
- func (s *Service) Page(path string, p view.Page)
- func (s *Service) Path(p string) string
- func (s *Service) Post(path string, handlers ...web.Handler)
- func (s *Service) Put(path string, handlers ...web.Handler)
- func (s *Service) Run()
- func (s *Service) RunTask(ctx context.Context, path string, params url.Values) (*asynctask.TaskStatus, error)
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) URLPrefix() string
- func (s *Service) Use(handlers ...web.Handler)
- func (s *Service) WithNamespace(ctx context.Context) context.Context
- type Task
Constants ¶
This section is empty.
Variables ¶
var ContextKey = xcontext.NewKey("service")
ContextKey is a key to get a service.
var CronTimezone = "Asia/Tokyo"
CronTimezone is a timezone used in cron.yaml
Functions ¶
func NewHTTPClient ¶
NewHTTPClient returns *http.Client under the gae service context
Types ¶
type BuiltInAPIConfig ¶
BuiltInAPIConfig is a configuration object for setupBuiltInAPIs
type Service ¶
type Service struct { Init func(*web.Request) Every func(*web.Request) OnError func(*web.Request, error) *response.Response Config *config.Config // Configuration that admin can update. APIConfig *BuiltInAPIConfig // contains filtered or unexported fields }
Service is a set of endpoints
func FromContext ¶
FromContext returns a service object associated with the context
func MustFromContext ¶
MustFromContext is like FromContext but panics if a service is not in the context
func NewWithURLAndNamespace ¶
NewWithURLAndNamespace is like New with using the given url prefix and namespece instead of 'key' value.
func (*Service) AddPushQueue ¶
AddPushQueue adds a named queue into the service.
func (*Service) GenCronYAML ¶
GenCronYAML generates cron yaml content to `w`
func (*Service) GenQueueYAML ¶
GenQueueYAML generates cron yaml content to `w`
func (*Service) ServeHTTP ¶
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler#ServeHTTP