Giter VIP home page Giter VIP logo

http's People

Contributors

ragboyjr avatar

Stargazers

 avatar

Watchers

 avatar  avatar

http's Issues

Verbose Exception Handlers

            return $rf(500, [], \vnu\api\error_struct('unhandled_exception', $ex->getMessage(), [
                'exception' => [
                    'line' => $ex->getLine(),
                    'previous' => $ex->getPrevious(),
                    'file' => $ex->getFile(),
                    'trace' => explode("\n", $ex->getTraceAsString()),
                ]
            ]));
        });

Http Request

Create an HTTP request wrapper to add several convenience methods.

Alias URI Path Middleware

function aliasUriPath($app, $from, $to) {
    return function($req, $next) use ($app, $from, $to) {
        $from = Mw\Http\Util\joinUri($app['routes']->getPrefix(), $from);
        $to = Mw\Http\Util\joinUri($app['routes']->getPrefix(), $to);

        $path = $req->getUri()->getPath();
        if ($path == $from || strpos($path, $from . '/') === 0) {
            $to = str_replace($from, $to, $path);
            $req = $req->withUri(
                $req->getUri()->withPath($to)
            );
        }

        return $next($req);
    };
}

Stream Marshal Response

        $admin['stacks.marshal_response']->push(function($res, $rf, $req, $next) {
            if (!$res instanceof \Psr\Http\Message\StreamInterface) {
                return $next($res, $rf, $req);
            }

            return $rf(200, [], $res);
        });

EnvPackage

We need an env package that sets $app['env'] and will use the DotEnv.

Redirect Marshal Response Matching

The redirect marshal response is incorrectly matching this: return [404, 'Feed Not Found']

Instead it should return a string body with 404 error status.

Url Builder

Build a simple class or function that builds full urls from mounted middleware. In a mounted middleware, the original request uri is backed up and replaced with the path relative to the mount. However, if one were to link urls, the urls would be wrong because they don't include the full path. The url builder takes a request and will prepend the proper path.

Rename to Krak Http

Remove the Mw\Http namespace and just the Http namespace to allow separation from the Mw package where it originated from. Don't worry about changing documentation and packagist names to account for change. It'll just be an vestige for now.

Serve Static Middleware

function serveStatic($root) {
    return function($req, $next) use ($root) {
        $path = $req->getUri()->getPath();
        $file_path = $root . $path;
        if (!is_file($file_path)) {
            return $next($req);
        }

        return $next->response(200, [
            'Content-Type' => mime_content_type($file_path),
        ], fopen($file_path, "r"));
    };
}

Logging Package

Add a new logging package that adds application and request logging via monolog.

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.