Commit 9eac5e1d authored by Camil Staps's avatar Camil Staps 🍃

Cleanup iTasks.Extensions.Web

parent 063c7a9f
Pipeline #29232 passed with stage
in 5 minutes and 12 seconds
definition module iTasks.Extensions.Web
import iTasks
from Internet.HTTP import :: HTTPMethod, :: HTTPRequest, :: HTTPResponse
from Text.URI import :: URI
from Text.HTML import class html
/**
* This module provides support for building web applications.
*/
* This module provides support for building web applications.
*/
//* Uniform resource locators
:: URL = URL !String
......@@ -19,24 +21,38 @@ derive JSONDecode URL
derive gDefault URL
derive gEq URL
//Simple web server task
//* Simple web server task
serveWebService :: Int (HTTPRequest -> Task HTTPResponse) -> Task ()
//Task for serving a static file
//* Task for serving a static file
serveFile :: [FilePath] HTTPRequest -> Task HTTPResponse
/**
* Calls an external HTTP webservice.
*
* @param HTTP Method: the HTTP method (GET or POST) to use
* @param URL: The URL of the webservice
* @param Parameters: A list of name/value pairs
* @param Response handler: A parse function that parses the response
*
* @return The parsedd value
*
* @gin-title Call web service
* @gin-icon webservice
*/
* Calls an external HTTP webservice.
*
* @param HTTP Method: the HTTP method (GET or POST) to use
* @param URL: The URL of the webservice
* @param Data: The body of the request
* @param Response handler: A parse function that parses the response
*
* @return The parsed value
*
* @gin-title Call web service
* @gin-icon webservice
*/
callHTTP :: !HTTPMethod !URI !String !(HTTPResponse -> (MaybeErrorString a)) -> Task a | iTask a
/**
* Calls an external HTTP webservice.
*
* @param HTTP Method: the HTTP method (GET or POST) to use
* @param URL: The URL of the webservice
* @param Parameters: A list of name/value pairs
* @param Response handler: A parse function that parses the response
*
* @return The parsed value
*
* @gin-title Call web service
* @gin-icon webservice
*/
callRPCHTTP :: !HTTPMethod !URI ![(String,String)] !(HTTPResponse -> a) -> Task a | iTask a
implementation module iTasks.Extensions.Web
import iTasks
import iTasks.UI.Editor.Controls, iTasks.UI.Editor.Modifiers
import Internet.HTTP, Text, Text.HTML, Text.URI, Text.Encodings.MIME, Text.Encodings.UrlEncoding, StdArray, Data.Either
......@@ -14,7 +15,6 @@ import qualified Data.Map as DM
import Data.Map.GenJSON
import qualified Data.List as DL
//* URL
gText{|URL|} _ val = [maybe "" toString val]
gEditor{|URL|} = selectByMode
......@@ -215,5 +215,3 @@ callHTTP _ url _ _
callRPCHTTP :: !HTTPMethod !URI ![(String,String)] !(HTTPResponse -> a) -> Task a | iTask a
callRPCHTTP method url params transformResult
= callHTTP method url (urlEncodePairs params) (Ok o transformResult)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment