-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xojo_code
More file actions
110 lines (90 loc) · 2.42 KB
/
App.xojo_code
File metadata and controls
110 lines (90 loc) · 2.42 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#tag Class
Protected Class App
Inherits RestApi.ApiApplication
#tag Event
Sub ApiStartup()
Using RestApi
// set api root path
Self.ApiRootPath = "api"
// register api controller classes
Self.RegisterApi(GetTypeInfo(PingApi))
Self.RegisterApi(GetTypeInfo(TestApi))
End Sub
#tag EndEvent
#tag Event
Function Authenticate(request as WebRequest) As RestApi.AuthResult
Using RestApi
// uncomment below to activate Basic authentication on App level
// each ApiController can have its own Authorization setting.
// sample request: curl -H "Authorization: Basic SGVsbG86V29ybGQ=" localhost:8080/api/pig
If request.Header("Authorization") = "Basic " + Self.DefaultAuthHeader Then
Return AuthResult.permitted
Else
Return AuthResult.denied
end
End Function
#tag EndEvent
#tag Event
Function UnhandledException(error As RuntimeException) As Boolean
// TODO handle errors
End Function
#tag EndEvent
#tag Note, Name = Readme
Sample App to demonstrate how to use the RestApi.
See Lib/RestApi/Notes for more details...
#tag EndNote
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Var v As String = _
Str(app.MajorVersion) + "." + _
Str(app.MinorVersion) + "." + _
Str(app.BugVersion) + "." + _
Str(app.NonReleaseVersion)
Return v
End Get
#tag EndGetter
LongVersion As string
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Var v As String = _
Str(app.MajorVersion) + "." + _
Str(app.MinorVersion) + "." + _
Str(app.BugVersion)
Return v
End Get
#tag EndGetter
ShortVersion1 As string
#tag EndComputedProperty
#tag Constant, Name = DefaultAuthHeader, Type = String, Dynamic = False, Default = \"SGVsbG86V29ybGQ\x3D", Scope = Private
#tag EndConstant
#tag ViewBehavior
#tag ViewProperty
Name="ApiRootPath"
Visible=false
Group="Behavior"
InitialValue="api"
Type="String"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag ViewProperty
Name="ShortVersion1"
Visible=false
Group="Behavior"
InitialValue=""
Type="string"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag ViewProperty
Name="LongVersion"
Visible=false
Group="Behavior"
InitialValue=""
Type="string"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass