Verified Commit 02a196fe authored by Camil Staps's avatar Camil Staps
Browse files

Update references to cloogle.org to cloogle-web

parent 8a41a32d
......@@ -4,8 +4,8 @@ This repository describes the Cloogle API as a set of types. Because many
applications make assumptions about this API, one must be reluctant with
changing this. Sometimes, it is enough to change the Cloogle core or the web
frontend alone; see
[CONTRIBUTING.md](https://gitlab.com/cloogle/cloogle.org/blob/master/CONTRIBUTING.md)
in the cloogle.org repository for more information.
[CONTRIBUTING.md](https://gitlab.com/cloogle/cloogle-web/blob/master/CONTRIBUTING.md)
in the cloogle-web repository for more information.
## Dependent projects
......
definition module Cloogle.API
/**
* The API for Cloogle, a Clean search engine: https://cloogle.org.
* The API for Cloogle, a search engine for the Clean language.
*
* Copyright 2016-2021 the authors (see README.md).
*
......
......@@ -25,6 +25,19 @@ from Internet.HTTP import :: HTTPRequest
import Cloogle.API
toHTTPRequest :: !Request -> HTTPRequest
/**
* Create a `HTTPRequest` from a Cloogle `Request`.
* This function does not actually perform the request; see `request`.
* @param The server to use, e.g. `example.org`.
* @param The Cloogle `Request`.
* @result The corresponding `HTTPRequest`.
*/
toHTTPRequest :: !String !Request -> HTTPRequest
request :: !Request !*World -> *(MaybeErrorString Response, *World)
/**
* Perform a Cloogle `Request` and return a `Response`.
* @param The server to connect to, e.g. `example.org`.
* @param The Cloogle `Request`.
* @result The `Response`, or an error.
*/
request :: !String !Request !*World -> *(MaybeErrorString Response, *World)
......@@ -25,6 +25,7 @@ import Data.Error
from Data.Func import $
import Data.Functor
import Data.Map
import Data.Maybe
import Data.Tuple
import Internet.HTTP
from Text import class Text(join), instance Text String, instance + String
......@@ -33,14 +34,14 @@ import Text.GenJSON
import Cloogle.API
toHTTPRequest :: !Request -> HTTPRequest
toHTTPRequest req =
toHTTPRequest :: !String !Request -> HTTPRequest
toHTTPRequest server req =
{ newHTTPRequest
& req_method = HTTP_GET
, req_path = "/api.php"
, req_query = "?" + urlEncodePairs params
, req_headers = put "User-Agent" "Clean/libcloogle" newMap
, server_name = "cloogle.org"
, server_name = server
}
where
params = catMaybes
......@@ -53,8 +54,8 @@ where
]
where printBool b = if b "true" "false"
request :: !Request !*World -> *(MaybeErrorString Response, *World)
request req w = appFst ((=<<) parseResponse) $ doHTTPRequest (toHTTPRequest req) 10000 w
request :: !String !Request !*World -> *(MaybeErrorString Response, *World)
request server req w = appFst ((=<<) parseResponse) $ doHTTPRequest (toHTTPRequest server req) 10000 w
where
parseResponse :: HTTPResponse -> MaybeErrorString Response
parseResponse res = case fromJSON $ fromString res.rsp_data of
......
# libcloogle
This repository holds types for [Cloogle][], the [Clean][] language search engine.
It is used in the core system at
This repository holds types for Cloogle, a search engine for the [Clean][]
language. It is used in the core system at
[cloogle/Cloogle](https://gitlab.com/cloogle/Cloogle).
These types can be used to easily access the TCP and HTTP APIs at
[cloogle.org][Cloogle] (source code at
[cloogle/cloogle.org](https://gitlab.com/cloogle/cloogle.org)),
These types can be used to easily access the TCP and HTTP APIs at a server
running the web frontend (source code at
[cloogle/cloogle-web](https://gitlab.com/cloogle/cloogle-web)),
using the generic JSON functions on these types.
## Authors &amp; License
......@@ -21,4 +21,3 @@ This project is licensed under GPL v3; see the [LICENSE](/LICENSE) file.
[Camil Staps]: https://camilstaps.nl
[Clean]: http://clean.cs.ru.nl
[Cloogle]: https://cloogle.org
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