Giter Site home page Giter Site logo

arachnid's Introduction

Arachnid

Catch API requests in your web. Arachnid logs selected endpoints to your database for later usage, and allows storing custom data on logs for custom interfaces and other usage.

How to Use

Arachnid is currently opt-in by endpoints. In your register_rest_route call, simply add 'arachnid_log' => true.

You can also add custom data to the log entry by setting the arachnid_log_callback parameter in your registration, which specifies a callback to call after the entry has been created. This callback takes three parameters: the Entry item, the WP_REST_Request that generated the request, and your response data.

The Entry object has a bunch of methods in the public API, including get_meta( $key, $default = null ) and set_meta( $key, $value ) for storing your custom data. (Unlike WP's meta, this is a key-value store and cannot hold multiple items.)

For example:

register_rest_route( 'example/v1', '/foo', [
	'methods' => 'GET, POST',
	'callback' => '__return_false',

	'arachnid_log' => true,
	'arachnid_log_callback' => function ( \Arachnid\Entry $entry, $request, $response ) {
		$entry->set_meta( 'foo', 'bar' );
	}
]);

arachnid's People

Contributors

aaronjorbin avatar joehoyle avatar rmccue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arachnid's Issues

Track uncaught exceptions on requests

If we hit an exception on a request, we should catch it, log it, and ensure the log item is still saved.

  • Add a catch-all exception handler in middleware
  • Save the exception as the response
  • Dump the exception in the UI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.