eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HTTPSimpleJSONRestService':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: HTTPSimpleJSONRestService


Inheritance:

   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

Description:


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:]

copyright

COPYRIGHT (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.

Instance protocol:

call entries
o  protocolInfo
walk along superclass chain, up to myself

request handling
o  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.

o  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.

o  reportNotFound: errMsg moreInfo: moreInfo for: aRequest


Private classes:

    RestCallAnnotation


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 08:31:47 GMT