|
Class: HTTPSimpleJSONRestService
Object
|
+--HTTPService
|
+--HTTPRestService
|
+--HTTPSimpleJSONRestService
- Package:
- stx:goodies/webServer
- Category:
- Net-Communication-Rest
- Version:
- rev:
1.40
date: 2024/01/25 15:09:31
- user: stefan
- file: HTTPSimpleJSONRestService.st directory: goodies/webServer
- module: stx stc-classLibrary: webServer
Abstract superclass for JSON based Rest services.
This answers with a method's return value.
Callable methods are automatically detected by their 'RestCallEntry:' annotation.
See concrete subclasses on how call entries are defined (via the annotation).
Also provides a common 'protocolInfo' entry, which allows querying the supported entries.
[start Server with:]
HTTPServer startServerOnPort:9876
[request:]
(HTTPServer runningServerOnPort:9876) debugErrors:true.
|data|
data := HTTPInterface getFile:'localHost:9876/rest/protocolInfo'.
data := JSONReader fromJSON:data.
Transcript showCR:data
[instance variables:]
[class variables:]
copyrightCOPYRIGHT (c) 2015 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
call entries
-
protocolInfo
-
walk along superclass chain, up to myself
request handling
-
process: aRequest
-
handles requests of the form:
<baseUrl>/relPath
and searches for a method with
RestCallEntry: 'relPath'
annotation.
Then this is called with the request and the json decoded argument (or nil).
It is the responsibility of the method to determine if it is a GET, PUT or DELETE, by checking the request.
The returned object is then encoded to json and returned.
-
process: aRequest method: typeOfRequest relativePath: relPath argument: callArgument
-
handles requests of the form:
<baseUrl>/relPath
and searches for a method with
RestCallEntry: 'relPath'
annotation.
Then this is called with the request and the json decoded argument (or nil).
It is the responsibility of the method to determine if it is a GET, PUT or DELETE by checking the request.
The returned object is then encoded to json and returned.
-
reportNotFound: errMsg moreInfo: moreInfo for: aRequest
-
RestCallAnnotation
|