Skip to content

MayRest

Dan M edited this page Mar 29, 2022 · 6 revisions

MayRest is a wrapper around the standard dart http library, that generally simplifies calls.

It has some useful features like being able to set default headers, and a token, so that you don't have to specify them in every call.


API

Static Fields

static String? userToken

This is the token that will be used when generating the headers for requests. If null, no Authorization header is sent.

static Map<String, String> defaultHeaders

These are the default headers added to every api call made. If you pass anything into the headers field of a call, these will be overridden. Defaults to:

static Map<String, String> defaultHeaders = {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  };

Static Methods

static void disableColors

Disables the colors for the static MayRest Log object.

static Future<Response> get(String url, {bool quiet, bool noToken, Map<String, String>? headers})

Makes a get request to url. If quiet, no logs will show. If noToken, regardless of if userToken is set, no auth token will be passed. headers passed will override defaultHeaders

Future<Response> post(String url, dynamic body, {bool quiet, bool noToken, Map<String, String>? headers})

Posts body to url. All other parameters behave the same as get

Clone this wiki locally