Permalink
Browse files

fix #113: store request context

  • Loading branch information...
kamilsk committed Oct 16, 2018
1 parent 0c2069c commit 85c3f0e20a7a82db1dcf7fca46fdbf2717081747
@@ -1,5 +1,4 @@
TRUNCATE TABLE "link" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "schema" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "template" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "input" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "event" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "input" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "template" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "schema" RESTART IDENTITY RESTRICT;
@@ -5,14 +5,13 @@ DECLARE demoAccount "account"."id"%TYPE := '10000000-2000-4000-8000-1600000000
DECLARE form "schema"."id"%TYPE := '10000000-2000-4000-8000-160000000004';
DECLARE html "template"."id"%TYPE := '10000000-2000-4000-8000-160000000005';
BEGIN
TRUNCATE TABLE "account" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "event" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "input" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "template" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "schema" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "token" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "user" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "link" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "schema" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "template" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "input" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "event" RESTART IDENTITY RESTRICT;
TRUNCATE TABLE "account" RESTART IDENTITY RESTRICT;

INSERT INTO "account" ("id", "name") VALUES (demoAccount, 'Demo Account');

@@ -20,7 +20,7 @@ import (
var (
_ grpc.ProtectedStorage = storage.Must()
_ router.Server = server.New(config.ServerConfig{}, nil)
_ server.Service = service.New(config.ServiceConfig{}, nil, nil)
_ server.Service = service.New(config.ServiceConfig{TemplateDir: "static/templates"}, nil, nil)
_ service.Storage = storage.Must()
_ service.Tracker = storage.Must()
)
@@ -19,14 +19,10 @@ const (
)

const (
// RedirectKey TODO issue#173
RedirectKey = "_redirect"
// ResourceKey TODO issue#173
ResourceKey = "_resource"
// TemplateKey TODO issue#173
TemplateKey = "_template"
// TimeoutKey TODO issue#173
TimeoutKey = "_timeout"
redirectKey = "_redirect"
resourceKey = "_resource"
templateKey = "_template"
timeoutKey = "_timeout"
)

// Input represents an element of an HTML form.
@@ -49,7 +45,7 @@ type InputData url.Values

// Redirect TODO issue#173
func (d InputData) Redirect(fallback ...string) string {
value := url.Values(d).Get(RedirectKey)
value := url.Values(d).Get(redirectKey)
if value == "" {
for _, value = range fallback {
if value != "" {
@@ -62,12 +58,12 @@ func (d InputData) Redirect(fallback ...string) string {

// Resource TODO issue#173
func (d InputData) Resource() ID {
return ID(url.Values(d).Get(ResourceKey))
return ID(url.Values(d).Get(resourceKey))
}

// Template TODO issue#173
func (d InputData) Template() *ID {
var id = ID(url.Values(d).Get(TemplateKey))
var id = ID(url.Values(d).Get(templateKey))
if id.IsValid() {
return &id
}
@@ -76,7 +72,7 @@ func (d InputData) Template() *ID {

// Timeout TODO issue#173
func (d InputData) Timeout() time.Duration {
timeout, err := time.ParseDuration(url.Values(d).Get(TimeoutKey))
timeout, err := time.ParseDuration(url.Values(d).Get(timeoutKey))
if err != nil {
return 30 * time.Second
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 85c3f0e

Please sign in to comment.