question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support CalDAV methods

See original GitHub issue

According to your documentation, the methods contained in the CalDAV specifications (e.g. REPORT) are not included.

On your readme.md you claim:

Use Express-like routing syntax to capture outgoing requests.

However, express supports these routing methods: http://expressjs.com/en/5x/api.html#routing-methods

Are you interested in support them at at one point?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TimDaubcommented, Jul 27, 2020
1reaction
kettanaitocommented, Jul 21, 2020

to have an api that allows me to easily create my own namespace (for e.g. caldav)

There is such API, actually. It’s not documented yet, but you can create your own request handlers as long as they abide the request handler API. Here’s an example:

// src/mocks/handlers/caldav.js
import { restContext } from 'msw'

export function createCalDAVHandler(method) {
  return (mask, resolver) => {
    return {
      // Determine if a captured request is a CalDAV request.
      predicate(req) {
        const hasMatchingUrl = compareTwoUrls(req.url, mask)
        const hasSameMethod = req.method === method

        return hasSameMethod && hasMatchingUrl
      },

      // Define which functions are exposed in `ctx.*()`.
      // Here, let's return the same map of functions
      // that's used for `rest.*()` handlers.
      defineContext() {
        return restContext
      },

      // Pass response resolver as-is.
      resolver,
    }
  }
}

export const caldav = {
  report: createCalDAVHandler('REPORT')
}

Once defined, you can use that custom request handler:

import { setupWorker } from 'msw'
import { caldav } from './caldav'

const worker = setupWorker(
  caldav.report('/user', (req, res, ctx) => {...})
)

worker.start()

That is, basically, how such namespace would be implemented internally in MSW.

This is a bare example, and it may not be enough for complete usage, but it should give you an idea. I agree that this API needs to be refined and documented, and this is on the documentation improvement roadmap.

I’m thankful if you give it a try and share the insights with us!

Read more comments on GitHub >

github_iconTop Results From Across the Web

CalDAV API Developer's Guide | Google Calendar
Supports the HTTP methods GET , PUT , HEAD , DELETE , POST , OPTIONS , PROPFIND and PROPPATCH . Does not support...
Read more >
Building a CalDAV client - sabre/dav
Most HTTP clients should just support methods they don't know about, so it's wise to simply use a stock HTTP client (or better...
Read more >
Documentation: caldav 0.11.0 - Read the Docs
Objective and scope¶. The python caldav library should make interactions with calendar servers simple and easy. Simple operations (like find a list of...
Read more >
RFC 4791: Calendaring Extensions to WebDAV (CalDAV)
1. MKCALENDAR Method An HTTP request using the MKCALENDAR method creates a new calendar collection resource. · 2. Creating Calendar Object Resources Clients ......
Read more >
CalDAV - Wikipedia
Calendaring Extensions to WebDAV, or CalDAV, is an Internet standard allowing a client to access and manage calendar data along with the ability...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found