test url parser

master
謝桂綱 10 years ago
parent 0a3bd2ce70
commit 3e05afebd4

@ -9,6 +9,9 @@ Module Module1
Sub Main()
Dim svr As New RQL.RESTProvider
Call svr.Run()
Dim stststs = LDM.Statements.LinqStatement.TryParse( _
_
"From x As Integer In ""E:\Microsoft.VisualBasic.Parallel\trunk\LINQ\ints.txt"" Let add = x + 50 Where add > 0 Let cc = add ^ 2 let abc as double = cc mod 99 +11.025R Select abc, cc, x, add, nn = cc+ x/ add * 22 mod 5, gg = math.max(cc,add)")

@ -150,6 +150,14 @@
<Project>{fecce1fd-e1d4-49e3-a668-60bb5e7aed99}</Project>
<Name>+Microsoft.VisualBasic.Architecture.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\REST_Framework\HTTPServer\SMRUCC.HTTPInternal\SMRUCC.HTTPInternal.vbproj">
<Project>{fbfc1455-b232-4f16-afc7-4054a8b864ab}</Project>
<Name>SMRUCC.HTTPInternal</Name>
</ProjectReference>
<ProjectReference Include="..\..\RQL\RQL.vbproj">
<Project>{bc922a27-9bc3-4e7e-be3d-55fc03fb4160}</Project>
<Name>RQL</Name>
</ProjectReference>
<ProjectReference Include="..\LINQ\Linq.vbproj">
<Project>{0a9b9fa6-e12d-48fd-b979-9f021a591e69}</Project>
<Name>Linq</Name>

@ -1,4 +1,5 @@
Imports Microsoft.VisualBasic.CommandLine.Reflection
Imports Microsoft.VisualBasic.ComputingServices.TaskHost
Imports SMRUCC.HTTPInternal.AppEngine
Imports SMRUCC.HTTPInternal.AppEngine.APIMethods
Imports SMRUCC.HTTPInternal.Platform
@ -6,33 +7,7 @@ Imports SMRUCC.HTTPInternal.Platform
''' <summary>
''' LinqWebApp
''' </summary>
<[Namespace]("Linq")>
Public Class LinqAPI : Inherits WebApp
Public Class LinqAPI : Inherits LinqPool
Sub New(main As PlatformEngine)
Call MyBase.New(main)
End Sub
''' <summary>
''' APIlinq
''' </summary>
''' <param name="uri"></param>
''' <param name="args"></param>
''' <param name="out"></param>
''' <returns></returns>
Public Function ExecLinq(uri As String, args As String, ByRef out As String) As Boolean
End Function
<ExportAPI("/linq/move_next.vb",
Info:="Execute linq iterator move next and then returns a data set. If the n number parameter is default 1, then a single object will returns, or a array of object will be returns.",
Usage:="/linq/move_next.vb?uid=&lt;hashCode>&n=&lt;numbers,default is 1>")>
<[GET](GetType(String))>
Public Function MoveNext(args As String) As String
End Function
Public Overrides Function Page404() As String
Return PlatformEngine.Page404
End Function
End Class

@ -6,12 +6,12 @@ Imports Microsoft.VisualBasic.Serialization
Imports SMRUCC.HTTPInternal.Core
''' <summary>
''' 线
''' 线url
''' </summary>
Public Class RESTProvider : Inherits HttpServer
Public ReadOnly Property Repository As Repository
Public ReadOnly Property LinqProvider As LinqPool = New LinqPool
Public ReadOnly Property LinqProvider As LinqAPI = New LinqAPI
''' <summary>
'''
@ -23,6 +23,10 @@ Public Class RESTProvider : Inherits HttpServer
Me.Repository = repo
End Sub
Sub New()
Call Me.New(80, RQL.Repository.LoadDefault)
End Sub
''' <summary>
''' http://linq.gcmodeller.org/kegg/pathways?where=test_expr(pathway)
''' 使url
@ -32,16 +36,26 @@ Public Class RESTProvider : Inherits HttpServer
''' <param name="p"></param>
''' <return>IpEndPoint</return>
Public Overrides Sub handleGETRequest(p As HttpProcessor)
If p.IsWWWRoot Then
'
Else
Call __apiInvoke(p)
End If
End Sub
Private Sub __apiInvoke(p As HttpProcessor)
Dim url As String = p.http_url
Dim pos As Integer = InStr(url, "?")
Dim expr As String = ""
If pos = 0 Then
' expr
Else
expr = Mid(url, pos + 1).Trim
expr = Mid(url, pos + 1).Trim '
expr = expr.URLEscapes
url = Mid(url, 1, pos - 1)
End If
Dim source = Repository.GetRepository(url, expr) ' exprwhere
Dim source As IEnumerable = Repository.GetRepository(url, expr) ' exprwhere
Dim linq As IPEndPoint = LinqProvider.OpenQuery(source, Repository.GetType(url))
Call p.outputStream.WriteLine(linq.GetJson)
End Sub

@ -15,7 +15,7 @@ Public Class Repository : Implements ISaveHandle
''' {lower_case.url, type_info}
''' </summary>
''' <returns></returns>
Public ReadOnly Property Models As Dictionary(Of String, EntityProvider)
Public Property Models As New Dictionary(Of String, EntityProvider)
ReadOnly __types As TypeRegistry
ReadOnly __api As APIProvider
@ -44,11 +44,20 @@ Public Class Repository : Implements ISaveHandle
Return api.GetType
End Function
Public Function LoadFile(url As String) As Repository
Return LoadJsonFile(Of Repository)(url)
Public Shared Function LoadFile(url As String) As Repository
Try
Return LoadJsonFile(Of Repository)(url)
Catch ex As Exception
ex = New Exception(url, ex)
Call App.LogException(ex)
Dim __new As New Repository
Call __new.Save(url, Encodings.ASCII)
Return __new
End Try
End Function
Public Function LoadDefault() As Repository
Public Shared Function LoadDefault() As Repository
Return LoadFile(DefaultFile)
End Function

Loading…
Cancel
Save